JavaScript: String Object

By Xah Lee. Date: . Last updated: .

String is the value of the property key "String" of the global object.

console.log( window.hasOwnProperty ( "String" ) ) // true

String is a function object.

〔►see JavaScript: Data Types

// type of String
console.log ( typeof String === "function" ); // true
console.log ( === "[object Function]" ) // true

The parent of String is Function.prototype. 〔►see JavaScript: Prototype and Inheritance

// parent of String
console.log ( Object.getPrototypeOf ( String ) === Function.prototype ); // true

The purpose of String is:

  1. String(value) is used to convert any (primitive or object) value to a string primitive.
  2. new String(value) is used to convert any (primitive or object) value to a string object.
  3. Used as a namespace to hold general purpose methods for working with string or character.
  4. Holds the property key "prototype". The value of String.prototype is the parent object of all string instances and string primitives.

String Constructor

JavaScript: String Constructor



〔►see JavaScript: String.prototype


〔►see JavaScript: String.fromCodePoint


〔►see JavaScript: String.fromCharCode


〔►see JavaScript: String.raw


ECMAScript 2015 §Text Processing#sec-string-objects

String Topic

  1. JavaScript: Default Charset/Encoding
  2. JavaScript: String is 16-Bit Unit Sequence
  3. JavaScript: Unicode Character Escape Sequence
  4. JavaScript: Allowed Characters in Identifier
  5. HTML: Allowed Characters in id Attribute
  6. HTML: Character Sets and Encoding
  7. HTML XML Entities

  1. JavaScript: Template String
  2. JavaScript: Convert String to Number
  3. JavaScript Encode URL, Escape String
  4. JavaScript: Format Number
  5. JavaScript: JSON Object

  1. JavaScript: String Object
  2. JavaScript: String.prototype
  3. JavaScript: String Constructor

RegExp Topic

  1. JavaScript: RegExp Tutorial
  2. JavaScript: String Methods for RegExp
  3. JavaScript: RegExp Object
  4. JavaScript: RegExp Constructor
  5. JavaScript: RegExp.prototype
  6. JavaScript: RegExp Syntax
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.