String in ECMAScript 262
Basic object.
Inherits from:
Instance Properties
name | type | description |
---|---|---|
constructor | Object | A reference to the constructor class for the current object instance. [from Object] |
length | Number | (read only) The number of characters in the string. |
prototype | Object | The prototype for a class. [from Object] |
Instance Methods
name | returns | description |
---|---|---|
charAt(pos) | String | Return the character at a particular index in the string. |
charCodeAt(pos) | Number | Return the Unicode value of the character at a particular index in the string. |
concat([string1],[string2],[...]) | String | Append one or more strings to the current string, and return the result. |
fromCharCode([charCode0],[charCode1],[...]) | String | Create a new string from a series of Unicode character values. |
hasOwnProperty(propertyOrMethodName) | Boolean | Determines if the object/instance itself has the named property or method. [from Object] |
indexOf(searchString,[position]) | String | Find the offset of a substring within the string. |
isPrototypeOf(instanceToTest) | Boolean | Determines if the calling object prototype is in the inheritance chain for the supplied argument. [from Object] |
lastIndexOf(searchString,[position]) | String | The offset of a substring within the string. |
localeCompare(compareString) | Number | Compare the string to the argument in the current locale. |
match(expr) | Array | Run the supplied regular expression against the string and return an array of the results. |
propertyIsEnumerable(propertyOrMethodName) | Boolean |
Determines if the object/instance itself has a property or method of the supplied name which will appear in a for (prop in obj) enumeration.
[from Object]
|
replace(searchExpr,replaceExpr) | String | Find and replace values in a string, and return the changed string. |
search(searchExpr) | Number | Find the offset of a regular expression within the string. |
slice(start,[end]) | String | Return a specified subsection of the string. |
split([separator],[limit]) | Array | Separate the string into pieces and return an array of the resulting substrings. |
substring(start,[end]) | String | Return a specified subsection of the string. |
toLocaleLowerCase() | String | Return a locale-specific lowercase version of the string. |
toLocaleString() | String |
For most objects, the same as toString() unless explicitly overridden.
[from Object]
|
toLocaleUpperCase() | String | Return a locale-specific uppercase version of the string. |
toLowerCase() | String | Return a lowercase version of the string. |
toString() | String | Returns a string representation of the object. [from Object] |
toUpperCase() | String | Return an uppercase version of the string. |
valueOf() | String |
Returns the internal this value of the object.
[from Object]
|
Description
Strings may be constructed using the var foo = new String('string content')
constructor, or simply the string literal var foo = 'string content'
. Strings defined using a string literal cannot have custom properties, whereas strings defined using the new String("...")
constructor can:
var msg1 = "Hello World";
var msg2 = new String("Hello World");
msg1.foo=99;
msg2.foo=99;
// ** msg1.foo is undefined
// ** msg2.foo is 99
Strings may be delimited by either "
or '
in pairs; there is no difference between the two other than which is convenient for the particular application. Either character may be used inside such a string by escaping it with a backslash (\).
var msg1 = "Hello World!";
var msg2 = 'Hello World';
var storeName = "Gavin's House of Chips";
var nickName = 'Gavin "The Burninator" Kistner';
var quote = "Did he really say, \"Bob's your uncle?\"";
The shortest (albeit perhaps not the most clear) way of converting any other object type into a string is to concatenate an empty string onto the object. Doing so implicitly calls the toString()
method of that object:
var myAge=12;
var myAgeAsString = myAge+"";
Properties that are a String
Methods that return a String
name | of object | description |
---|---|---|
appendItem(newItem) | SVGStringList | |
charAt(pos) | String | Return the character at a particular index in the string. |
concat([string1],[string2],[...]) | String | Append one or more strings to the current string, and return the result. |
decode(str) | Folder | Decode the input string according to RFC 2396. |
decode(str) | File | Decode the input string according to RFC 2396. |
encode(str) | Folder | Encode the input string according to RFC 2396. |
encode(str) | File | Encode the input string according to RFC 2396. |
fromCharCode([charCode0],[charCode1],[...]) | String | Create a new string from a series of Unicode character values. |
getAttribute(name) | Element | |
getAttributeNS(namespaceURI,localName) | Element | |
getItem(index) | SVGStringList | |
getName() | ActionReference | get name value for an ActionReference whose form is 'Name' |
getPropertyPriority(propertyName) | CSSStyleDeclaration | |
getPropertyValue(propertyName) | CSSStyleDeclaration | |
getRelativeURI([basePath]) | Folder | Calculate the path relative to another. |
getRelativeURI([basePath]) | File | Calculate the path relative to another. |
getString(index) | ActionList | get the value of an item of type string |
getString(key) | ActionDescriptor | get the value of a key of type string |
getStringValue() | CSSPrimitiveValue | |
html() | Selection |
Get the innerHTML for a DOM element.
|
indexOf(searchString,[position]) | String | Find the offset of a substring within the string. |
insert(tagName,beforeSelector) | EnterSelection | Create and insert new elements before existing ones, returning a selection of the new elements. |
insert(tagName,beforeSelector) | Selection | Create and insert new elements before existing ones, returning a selection of the new elements. |
insertItemBefore(newItem,index) | SVGStringList | |
item(index) | CSSStyleDeclaration | |
item(index) | MediaList | |
join([separator]) | Array | Returns a string representation of the array, separated by the delimiter of your choice. |
lastIndexOf(searchString,[position]) | String | The offset of a substring within the string. |
property(name) | Selection | Get the value of a DOM property. |
read([chars]) | File | Read the contents of the file. |
readch() | File | Read a single character. |
readln() | File | Read one line of text. |
removeItem(index) | SVGStringList | |
removeProperty(propertyName) | CSSStyleDeclaration | |
replace(searchExpr,replaceExpr) | String | Find and replace values in a string, and return the changed string. |
replaceItem(newItem,index) | SVGStringList | |
slice(start,[end]) | String | Return a specified subsection of the string. |
style(name) | Selection | Get the computed value of a CSS style property. |
substring(start,[end]) | String | Return a specified subsection of the string. |
substringData(offset,count) | CharacterData | |
text() | Selection |
Get the textContent for a DOM element.
|
toDateString() | Date | Return a string version of the date-only portion of the object. |
toExponential([fractionDigits]) | Number | Return the number formatted in scientific notation, with one digit before the decimal point and a specified number of digits after. |
toFixed([fractionDigits]) | Number | Return the number formatted with a specified number of digits after the decimal point. |
toLocaleLowerCase() | String | Return a locale-specific lowercase version of the string. |
toLocaleString() | Object |
For most objects, the same as toString() unless explicitly overridden.
|
toLocaleUpperCase() | String | Return a locale-specific uppercase version of the string. |
toLowerCase() | String | Return a lowercase version of the string. |
toPrecision(precision) | Number | Return the number as a string in either in fixed or exponential notation, with the specified number of digits. |
toString() | Object | Returns a string representation of the object. |
toString([radix]) | Number | Return the number as a string converted to a specified base. |
toTimeString() | Date | Return a string version of the time-only portion of the object. |
toUpperCase() | String | Return an uppercase version of the string. |
toUTCString() | Date | Returns a string form of the Date in a convenient, human-readable form in UTC. |
typeIDToCharID(typeID) | Application | Convert from a runtime ID to a character ID. |
typeIDToStringID(typeID) | Application | Convert from a runtime ID to a string ID. |
valueOf() | Object |
Returns the internal this value of the object.
|