Name
String — support for strings
Inherits from
Object → String
Constructor
newString(s)// Constructor functionString(s)// Conversion function
Arguments
sThe value to be stored in a String object or converted to a primitive string.
Returns
When String() is used as
a constructor with the new
operator, it returns a String object, which holds the string
s or the string representation of
s. When the String() constructor is used without the
new operator, it simply
converts s to a primitive string and
returns the converted value.
Properties
lengthThe number of characters in the string.
Methods
charAt()Extracts the character at a given position from a string.
charCodeAt()Returns the encoding of the character at a given position in a string.
concat()Concatenates one or more values to a string.
indexOf()Searches the string for a character or substring.
lastIndexOf()Searches the string backward for a character or substring.
localeCompare()Compares strings using locale-specific ordering.
match()Performs pattern matching with a regular expression.
replace()Performs a search-and-replace operation with a regular expression.
search()Searches a string for a substring that matches a regular expression.
slice()Returns a slice or substring of a string.
split()Splits a string into an array of strings, breaking at a specified delimiter string or regular expression.
substr()Extracts a substring of a string; a variant of
substring().substring()Extracts a substring of a string.
toLowerCase()Returns a copy of the string, with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access