Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1017027 of String

  • Revision slug: Web/JavaScript/Reference/Global_Objects/String
  • Revision title: String
  • Revision id: 1017027
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment

Revision Content

{{JSRef}}

The String global object is a constructor for strings, or a sequence of characters.

Syntax

String literals take the forms:

'string text'
"string text"
"中文 español English हिन्दी العربية português বাংলা русский 日本語 ਪੰਜਾਬੀ 한국어 தமிழ்"

Strings can also be created using the String global object directly:

String(thing)

Parameters

thing
Anything to be converted to a string.

Template strings

Since ECMAScript 2015, string literals can also be so-called Template strings:

`hello world`
`hello!
 world!`
`hello ${who}`
escape `<a>${who}</a>`

Escape notation

Beside regular, printable characters, special characters can be encoded using escape notation:

Code Output
\0 the NULL character
\' single quote
\" double quote
\\ backslash
\n new line
\r carriage return
\v vertical tab
\t tab
\b backspace
\f form feed
\uXXXX unicode codepoint
\u{X} ... \u{XXXXXX} unicode codepoint {{experimental_inline}}
\xXX the Latin-1 character

Unlike some other languages, JavaScript makes no distinction between single-quoted strings and double-quoted strings, therefore, the escape sequences above work in strings created with either single or double quotes.

Long literal strings

Sometimes, your code will include strings which are very long. Rather than having lines that go on endlessly, or wrap at the whim of your editor, you may wish to specifically break the string into multiple lines in the source code without affecting the actual string contents. There are two ways you can do this.

You can use the + operator to append multiple strings together, like this:

let longString = "This is a very long string which needs " +
                 "to wrap across multiple lines because " +
                 "otherwise my code is unreadable.";

Or you can use the backslash character ("\") at the end of each line to indicate that the string will continue on the next line. Make sure there is no space or any other character after the backslash (except for a line break), or as an indent; otherwise it will not work. That form looks like this:

let longString = "This is a very long string which needs \
to wrap across multiple lines because \
otherwise my code is unreadable.";

Both of these result in identical strings being created.

Description

Strings are useful for holding data that can be represented in text form. Some of the most-used operations on strings are to check their {{jsxref("String.length", "length")}}, to build and concatenate them using the + and += string operators, checking for the existence or location of substrings with the {{jsxref("String.prototype.indexOf()", "indexOf()")}} method, or extracting substrings with the {{jsxref("String.prototype.substring()", "substring()")}} method.

Character access

There are two ways to access an individual character in a string. The first is the {{jsxref("String.prototype.charAt()", "charAt()")}} method:

return 'cat'.charAt(1); // returns "a"

The other way (introduced in ECMAScript 5) is to treat the string as an array-like object, where individual characters correspond to a numerical index:

return 'cat'[1]; // returns "a"

For character access using bracket notation, attempting to delete or assign a value to these properties will not succeed. The properties involved are neither writable nor configurable. (See {{jsxref("Object.defineProperty()")}} for more information.)

Comparing strings

C developers have the strcmp() function for comparing strings. In JavaScript, you just use the less-than and greater-than operators:

var a = 'a';
var b = 'b';
if (a < b) { // true
  console.log(a + ' is less than ' + b);
} else if (a > b) {
  console.log(a + ' is greater than ' + b);
} else {
  console.log(a + ' and ' + b + ' are equal.');
}

A similar result can be achieved using the {{jsxref("String.prototype.localeCompare()", "localeCompare()")}} method inherited by String instances.

Distinction between string primitives and String objects

Note that JavaScript distinguishes between String objects and primitive string values. (The same is true of {{jsxref("Boolean")}} and {{jsxref("Global_Objects/Number", "Numbers")}}.)

String literals (denoted by double or single quotes) and strings returned from String calls in a non-constructor context (i.e., without using the {{jsxref("Operators/new", "new")}} keyword) are primitive strings. JavaScript automatically converts primitives to String objects, so that it's possible to use String object methods for primitive strings. In contexts where a method is to be invoked on a primitive string or a property lookup occurs, JavaScript will automatically wrap the string primitive and call the method or perform the property lookup.

var s_prim = 'foo';
var s_obj = new String(s_prim);

console.log(typeof s_prim); // Logs "string"
console.log(typeof s_obj);  // Logs "object"

String primitives and String objects also give different results when using {{jsxref("Global_Objects/eval", "eval()")}}. Primitives passed to eval are treated as source code; String objects are treated as all other objects are, by returning the object. For example:

var s1 = '2 + 2';             // creates a string primitive
var s2 = new String('2 + 2'); // creates a String object
console.log(eval(s1));        // returns the number 4
console.log(eval(s2));        // returns the string "2 + 2"

For these reasons, code may break when it encounters String objects when it expects a primitive string instead, although generally authors need not worry about the distinction.

A String object can always be converted to its primitive counterpart with the {{jsxref("String.prototype.valueOf()", "valueOf()")}} method.

console.log(eval(s2.valueOf())); // returns the number 4
Note: For another possible approach to strings in JavaScript, please read the article about StringView — a C-like representation of strings based on typed arrays.

Properties

{{jsxref("String.prototype")}}
Allows the addition of properties to a String object.

Methods

{{jsxref("String.fromCharCode()")}}
Returns a string created by using the specified sequence of Unicode values.
{{jsxref("String.fromCodePoint()")}} {{experimental_inline}}
Returns a string created by using the specified sequence of code points.
{{jsxref("String.raw()")}} {{experimental_inline}}
Returns a string created from a raw template string.

String generic methods

String generics are non-standard, deprecated and will get removed near future. Note that you can not rely on them cross-browser without using the shim that is provided below.

The String instance methods are also available in Firefox as of JavaScript 1.6 (not part of the ECMAScript standard) on the String object for applying String methods to any object:

var num = 15;
console.log(String.replace(num, /5/, '2'));

{{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}} are also available on {{jsxref("Array")}} methods.

The following is a shim to provide support to non-supporting browsers:

/*globals define*/
// Assumes all supplied String instance methods already present
// (one may use shims for these if not available)
(function() {
  'use strict';

  var i,
    // We could also build the array of methods with the following, but the
    //   getOwnPropertyNames() method is non-shimable:
    // Object.getOwnPropertyNames(String).filter(function(methodName) {
    //   return typeof String[methodName] === 'function';
    // });
    methods = [
      'quote', 'substring', 'toLowerCase', 'toUpperCase', 'charAt',
      'charCodeAt', 'indexOf', 'lastIndexOf', 'startsWith', 'endsWith',
      'trim', 'trimLeft', 'trimRight', 'toLocaleLowerCase',
      'toLocaleUpperCase', 'localeCompare', 'match', 'search',
      'replace', 'split', 'substr', 'concat', 'slice'
    ],
    methodCount = methods.length,
    assignStringGeneric = function(methodName) {
      var method = String.prototype[methodName];
      String[methodName] = function(arg1) {
        return method.apply(arg1, Array.prototype.slice.call(arguments, 1));
      };
    };

  for (i = 0; i < methodCount; i++) {
    assignStringGeneric(methods[i]);
  }
}());

String instances

Properties

{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'Properties')}}

Methods

Methods unrelated to HTML

{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'Methods_unrelated_to_HTML')}}

HTML wrapper methods

{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'HTML_wrapper_methods')}}

Examples

String conversion

It's possible to use String as a "safer" {{jsxref("String.prototype.toString()", "toString()")}} alternative, as although it still normally calls the underlying toString(), it also works for {{jsxref("null")}} and {{jsxref("undefined")}}. For example:

var outputStrings = [];
for (var i = 0, n = inputValues.length; i < n; ++i) {
  outputStrings.push(String(inputValues[i]));
}

Specifications

Specification Status Comment
{{SpecName('ES1')}} {{Spec2('ES1')}} Initial definition.
{{SpecName('ES5.1', '#sec-15.5', 'String')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-string-objects', 'String')}} {{Spec2('ES6')}}  
{{SpecName('ESDraft', '#sec-string-objects', 'String')}} {{Spec2('ESDraft')}}  

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatChrome("1")}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
\u{XXXXXX} {{CompatUnknown}} {{CompatGeckoDesktop("40")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}
\u{XXXXXX} {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("40")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

See also

Revision Source

<div>{{JSRef}}</div>

<p>The <strong><code>String</code></strong> global object is a constructor for strings, or a sequence of characters.</p>

<h2 id="Syntax">Syntax</h2>

<p>String literals take the forms:</p>

<pre class="syntaxbox">
<code>'string text'
"string text"
"中文 español English हिन्दी العربية português বাংলা русский 日本語 ਪੰਜਾਬੀ 한국어 தமிழ்"</code></pre>

<p>Strings can also be created using the <code>String</code> global object directly:</p>

<pre class="syntaxbox">
<code>String(thing)
</code></pre>

<h3 id="Parameters">Parameters</h3>

<dl>
 <dt><code>thing</code></dt>
 <dd>Anything to be converted to a string.</dd>
</dl>

<h3 id="Template_strings">Template strings</h3>

<p>Since ECMAScript 2015, string literals can also be so-called <a href="/en-US/docs/Web/JavaScript/Reference/template_strings">Template strings</a>:</p>

<pre class="brush: js">
<code>`hello world`</code>
`hello!
 world!`
<code>`hello ${who}`</code>
<code>escape `&lt;a&gt;${who}&lt;/a&gt;`</code></pre>

<dl>
</dl>

<h3 id="Escape_notation">Escape notation</h3>

<p>Beside regular, printable characters, special characters can be encoded using escape notation:</p>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Code</th>
   <th scope="col">Output</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><code>\0</code></td>
   <td>the NULL character</td>
  </tr>
  <tr>
   <td><code>\'</code></td>
   <td>single quote</td>
  </tr>
  <tr>
   <td><code>\"</code></td>
   <td>double quote</td>
  </tr>
  <tr>
   <td><code>\\</code></td>
   <td>backslash</td>
  </tr>
  <tr>
   <td><code>\n</code></td>
   <td>new line</td>
  </tr>
  <tr>
   <td><code>\r</code></td>
   <td>carriage return</td>
  </tr>
  <tr>
   <td><code>\v</code></td>
   <td>vertical tab</td>
  </tr>
  <tr>
   <td><code>\t</code></td>
   <td>tab</td>
  </tr>
  <tr>
   <td><code>\b</code></td>
   <td>backspace</td>
  </tr>
  <tr>
   <td><code>\f</code></td>
   <td>form feed</td>
  </tr>
  <tr>
   <td><code>\uXXXX</code></td>
   <td>unicode codepoint</td>
  </tr>
  <tr>
   <td><code>\u{X}</code> ... <code>\u{XXXXXX}</code></td>
   <td>unicode codepoint {{experimental_inline}}</td>
  </tr>
  <tr>
   <td><code>\xXX</code></td>
   <td>the Latin-1 character</td>
  </tr>
 </tbody>
</table>

<div class="note">
<p>Unlike some other languages, JavaScript makes no distinction between single-quoted strings and double-quoted strings, therefore, the escape sequences above work in strings created with either single or double quotes.</p>
</div>

<dl>
</dl>

<h3 id="Long_literal_strings">Long literal strings</h3>

<p>Sometimes, your code will include strings which are very long. Rather than having lines that go on endlessly, or wrap at the whim of your editor, you may wish to specifically break the string into multiple lines in the source code without affecting the actual string contents. There are two ways you can do this.</p>

<p>You can use the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Addition_()">+</a> operator to append multiple strings together, like this:</p>

<pre class="brush: js">
let longString = "This is a very long string which needs " +
                 "to wrap across multiple lines because " +
                 "otherwise my code is unreadable.";
</pre>

<p>Or you can use the backslash character ("\") at the end of each line to indicate that the string will continue on the next line. Make sure there is no space or any other character after the backslash (except for a line break), or as an indent; otherwise it will not work. That form looks like this:</p>

<pre class="brush: js">
let longString = "This is a very long string which needs \
to wrap across multiple lines because \
otherwise my code is unreadable.";
</pre>

<p>Both of these result in identical strings being created.</p>

<h2 id="Description">Description</h2>

<p>Strings are useful for holding data that can be represented in text form. Some of the most-used operations on strings are to check their {{jsxref("String.length", "length")}}, to build and concatenate them using the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/String_Operators">+ and += string operators</a>, checking for the existence or location of substrings with the {{jsxref("String.prototype.indexOf()", "indexOf()")}} method, or extracting substrings with the {{jsxref("String.prototype.substring()", "substring()")}} method.</p>

<h3 id="Character_access">Character access</h3>

<p>There are two ways to access an individual character in a string. The first is the {{jsxref("String.prototype.charAt()", "charAt()")}} method:</p>

<pre class="brush: js">
return 'cat'.charAt(1); // returns "a"
</pre>

<p>The other way (introduced in ECMAScript 5) is to treat the string as an array-like object, where individual characters correspond to a numerical index:</p>

<pre class="brush: js">
return 'cat'[1]; // returns "a"
</pre>

<p>For character access using bracket notation, attempting to delete or assign a value to these properties will not succeed. The properties involved are neither writable nor configurable. (See {{jsxref("Object.defineProperty()")}} for more information.)</p>

<h3 id="Comparing_strings">Comparing strings</h3>

<p>C developers have the <code>strcmp()</code> function for comparing strings. In JavaScript, you just use the <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators">less-than and greater-than operators</a>:</p>

<pre class="brush: js">
var a = 'a';
var b = 'b';
if (a &lt; b) { // true
  console.log(a + ' is less than ' + b);
} else if (a &gt; b) {
  console.log(a + ' is greater than ' + b);
} else {
  console.log(a + ' and ' + b + ' are equal.');
}
</pre>

<p>A similar result can be achieved using the {{jsxref("String.prototype.localeCompare()", "localeCompare()")}} method inherited by <code>String</code> instances.</p>

<h3 id="Distinction_between_string_primitives_and_String_objects">Distinction between string primitives and <code>String</code> objects</h3>

<p>Note that JavaScript distinguishes between <code>String</code> objects and primitive string values. (The same is true of {{jsxref("Boolean")}} and {{jsxref("Global_Objects/Number", "Numbers")}}.)</p>

<p>String literals (denoted by double or single quotes) and strings returned from <code>String</code> calls in a non-constructor context (i.e., without using the {{jsxref("Operators/new", "new")}} keyword) are primitive strings. JavaScript automatically converts primitives to <code>String</code> objects, so that it's possible to use <code>String</code> object methods for primitive strings. In contexts where a method is to be invoked on a primitive string or a property lookup occurs, JavaScript will automatically wrap the string primitive and call the method or perform the property lookup.</p>

<pre class="brush: js">
var s_prim = 'foo';
var s_obj = new String(s_prim);

console.log(typeof s_prim); // Logs "string"
console.log(typeof s_obj);  // Logs "object"
</pre>

<p>String primitives and <code>String</code> objects also give different results when using {{jsxref("Global_Objects/eval", "eval()")}}. Primitives passed to <code>eval</code> are treated as source code; <code>String</code> objects are treated as all other objects are, by returning the object. For example:</p>

<pre class="brush: js">
var s1 = '2 + 2';             // creates a string primitive
var s2 = new String('2 + 2'); // creates a String object
console.log(eval(s1));        // returns the number 4
console.log(eval(s2));        // returns the string "2 + 2"
</pre>

<p>For these reasons, code may break when it encounters <code>String</code> objects when it expects a primitive string instead, although generally authors need not worry about the distinction.</p>

<p>A <code>String</code> object can always be converted to its primitive counterpart with the {{jsxref("String.prototype.valueOf()", "valueOf()")}} method.</p>

<pre class="brush: js">
console.log(eval(s2.valueOf())); // returns the number 4
</pre>

<div class="note"><strong>Note:</strong> For another possible approach to strings in JavaScript, please read the article about <a href="/en-US/Add-ons/Code_snippets/StringView"><code>StringView</code>&nbsp;— a C-like representation of strings based on typed arrays</a>.</div>

<h2 id="Properties">Properties</h2>

<dl>
 <dt>{{jsxref("String.prototype")}}</dt>
 <dd>Allows the addition of properties to a <code>String</code> object.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{jsxref("String.fromCharCode()")}}</dt>
 <dd>Returns a string created by using the specified sequence of Unicode values.</dd>
 <dt>{{jsxref("String.fromCodePoint()")}} {{experimental_inline}}</dt>
 <dd>Returns a string created by using the specified sequence of code points.</dd>
 <dt>{{jsxref("String.raw()")}} {{experimental_inline}}</dt>
 <dd>Returns a string created from a raw template string.</dd>
</dl>

<h2 id="String_generic_methods"><code>String</code> generic methods</h2>

<div class="warning">
<p><strong>String generics are non-standard, deprecated and will get removed near future</strong>. Note that you can not rely on them cross-browser without using the shim that is provided below.</p>
</div>

<p>The <code>String</code> instance methods are also available in Firefox as of JavaScript 1.6 (<strong>not</strong> part of the ECMAScript standard) on the <code>String</code> object for applying <code>String</code> methods to any object:</p>

<pre class="brush: js">
var num = 15;
console.log(String.replace(num, /5/, '2'));
</pre>

<p>{{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}} are also available on {{jsxref("Array")}} methods.</p>

<p>The following is a shim to provide support to non-supporting browsers:</p>

<pre class="brush: js">
/*globals define*/
// Assumes all supplied String instance methods already present
// (one may use shims for these if not available)
(function() {
  'use strict';

  var i,
    // We could also build the array of methods with the following, but the
    //   getOwnPropertyNames() method is non-shimable:
    // Object.getOwnPropertyNames(String).filter(function(methodName) {
    //   return typeof String[methodName] === 'function';
    // });
    methods = [
      'quote', 'substring', 'toLowerCase', 'toUpperCase', 'charAt',
      'charCodeAt', 'indexOf', 'lastIndexOf', 'startsWith', 'endsWith',
      'trim', 'trimLeft', 'trimRight', 'toLocaleLowerCase',
      'toLocaleUpperCase', 'localeCompare', 'match', 'search',
      'replace', 'split', 'substr', 'concat', 'slice'
    ],
    methodCount = methods.length,
    assignStringGeneric = function(methodName) {
      var method = String.prototype[methodName];
      String[methodName] = function(arg1) {
        return method.apply(arg1, Array.prototype.slice.call(arguments, 1));
      };
    };

  for (i = 0; i &lt; methodCount; i++) {
    assignStringGeneric(methods[i]);
  }
}());
</pre>

<h2 id="String_instances"><code>String</code> instances</h2>

<h3 id="Properties_2">Properties</h3>

<div>{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'Properties')}}</div>

<h3 id="Methods_2">Methods</h3>

<h4 id="Methods_unrelated_to_HTML">Methods unrelated to HTML</h4>

<div>{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'Methods_unrelated_to_HTML')}}</div>

<h4 id="HTML_wrapper_methods">HTML wrapper methods</h4>

<div>{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/prototype', 'HTML_wrapper_methods')}}</div>

<h2 id="Examples">Examples</h2>

<h3 id="String_conversion">String conversion</h3>

<p>It's possible to use <code>String</code> as a "safer" {{jsxref("String.prototype.toString()", "toString()")}} alternative, as although it still normally calls the underlying <code>toString()</code>, it also works for {{jsxref("null")}} and {{jsxref("undefined")}}. For example:</p>

<pre class="brush: js">
var outputStrings = [];
for (var i = 0, n = inputValues.length; i &lt; n; ++i) {
  outputStrings.push(String(inputValues[i]));
}
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES1')}}</td>
   <td>{{Spec2('ES1')}}</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.5', 'String')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-string-objects', 'String')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-string-objects', 'String')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome("1")}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>\u{XXXXXX}</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("40")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>\u{XXXXXX}</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("40")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("DOMString")}}</li>
 <li><a href="/en-US/Add-ons/Code_snippets/StringView"><code>StringView</code>&nbsp;— a C-like representation of strings based on typed arrays</a></li>
 <li><a href="/en-US/docs/Web/API/DOMString/Binary">Binary strings</a></li>
</ul>
Revert to this revision