String in ECMAScript 262
Basic object.
Inherits from:
Instance Properties
| name | type | description |
|---|---|---|
| prototype | Object | The prototype for a class. [from Object] |
| 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. |
Instance Methods
| name | returns | description |
|---|---|---|
| toLocaleString() | String |
For most objects, the same as toString() unless explicitly overridden.
[from Object]
|
| valueOf() | String |
Returns the internal this value of the object.
[from Object]
|
| hasOwnProperty() | Boolean | Determines if the object/instance itself has the named property or method. [from Object] |
| isPrototypeOf() | Boolean | Determines if the calling object prototype is in the inheritance chain for the supplied argument. [from Object] |
| propertyIsEnumerable() | 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]
|
| fromCharCode() | String | Create a new string from a series of Unicode character values. |
| charCodeAt() | Number | Return the Unicode value of the character at a particular index in the string. |
| concat() | String | Append one or more strings to the current string, and return the result. |
| charAt() | String | Return the character at a particular index in the string. |
| lastIndexOf() | String | The offset of a substring within the string. |
| localeCompare() | Number | Compare the string to the argument in the current locale. |
| replace() | String | Find and replace values in a string, and return the changed string. |
| slice() | String | Return a specified subsection of the string. |
| split() | Array | Separate the string into pieces and return an array of the resulting substrings. |
| search() | Number | Find the offset of a regular expression within the string. |
| toLowerCase() | String | Return a lowercase version of the string. |
| toUpperCase() | String | Return an uppercase version of the string. |
| toLocaleLowerCase() | String | Return a locale-specific lowercase version of the string. |
| toLocaleUpperCase() | String | Return a locale-specific uppercase version of the string. |
| toString() | String | Returns a string representation of the object. [from Object] |
| indexOf() | String | Find the offset of a substring within the string. |
| match() | Array | Run the supplied regular expression against the string and return an array of the results. |
| substring() | String | Return a specified subsection of the string. |
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 99Strings 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 |
|---|---|---|
| substringData() | CharacterData | |
| getAttribute() | Element | |
| getAttributeNS() | Element | |
| item() | MediaList | |
| getPropertyValue() | CSSStyleDeclaration | |
| removeProperty() | CSSStyleDeclaration | |
| getPropertyPriority() | CSSStyleDeclaration | |
| item() | CSSStyleDeclaration | |
| getStringValue() | CSSPrimitiveValue | |
| toLocaleString() | Object |
For most objects, the same as toString() unless explicitly overridden.
|
| valueOf() | Object |
Returns the internal this value of the object.
|
| join() | Array | Returns a string representation of the array, separated by the delimiter of your choice. |
| fromCharCode() | String | Create a new string from a series of Unicode character values. |
| concat() | String | Append one or more strings to the current string, and return the result. |
| charAt() | String | Return the character at a particular index in the string. |
| lastIndexOf() | String | The offset of a substring within the string. |
| replace() | String | Find and replace values in a string, and return the changed string. |
| slice() | String | Return a specified subsection of the string. |
| toLowerCase() | String | Return a lowercase version of the string. |
| toUpperCase() | String | Return an uppercase version of the string. |
| toString() | Number | Return the number as a string converted to a specified base. |
| toFixed() | Number | Return the number formatted with a specified number of digits after the decimal point. |
| toExponential() | Number | Return the number formatted in scientific notation, with one digit before the decimal point and a specified number of digits after. |
| toLocaleLowerCase() | String | Return a locale-specific lowercase version of the string. |
| toLocaleUpperCase() | String | Return a locale-specific uppercase version of the string. |
| toPrecision() | Number | Return the number as a string in either in fixed or exponential notation, with the specified number of digits. |
| toDateString() | Date | Return a string version of the date-only portion of the object. |
| toTimeString() | Date | Return a string version of the time-only portion of the object. |
| read() | File | Read the contents of the file. |
| toUTCString() | Date | Returns a string form of the Date in a convenient, human-readable form in UTC. |
| decode() | Folder | Decode the input string according to RFC 2396. |
| decode() | File | Decode the input string according to RFC 2396. |
| encode() | Folder | Encode the input string according to RFC 2396. |
| encode() | File | Encode the input string according to RFC 2396. |
| getRelativeURI() | File | Calculate the path relative to another. |
| getRelativeURI() | Folder | Calculate the path relative to another. |
| readch() | File | Read a single character. |
| readln() | File | Read one line of text. |
| typeIDToCharID() | Application | Convert from a runtime ID to a character ID. |
| typeIDToStringID() | Application | Convert from a runtime ID to a string ID. |
| getString() | ActionDescriptor | get the value of a key of type string |
| getString() | ActionList | get the value of an item of type string |
| getName() | ActionReference | get name value for an ActionReference whose form is 'Name' |
| getItem() | SVGStringList | |
| insertItemBefore() | SVGStringList | |
| replaceItem() | SVGStringList | |
| removeItem() | SVGStringList | |
| appendItem() | SVGStringList | |
| toString() | Object | Returns a string representation of the object. |
| indexOf() | String | Find the offset of a substring within the string. |
| substring() | String | Return a specified subsection of the string. |
Arguments that are a String
| name | in method | of object | description |
|---|---|---|---|
| newItem | insertItemBefore() | [svg] SVGStringList | |
| newItem | replaceItem() | [svg] SVGStringList | |
| newItem | appendItem() | [svg] SVGStringList | |
| rgbColor | setRGBColor() | [svg] SVGColor | |
| rgbColor | setRGBColorICCColor() | [svg] SVGColor | |
| iccColor | setRGBColorICCColor() | [svg] SVGColor | |
| rgbColor | setColor() | [svg] SVGColor | |
| iccColor | setColor() | [svg] SVGColor | |
| name | getPresentationAttribute() | [svg] SVGStylable | |
| extension | hasExtension() | [svg] SVGTests | |
| elementId | getElementById() | [svg] SVGSVGElement | |
| uri | setUri() | [svg] SVGPaint | |
| uri | setPaint() | [svg] SVGPaint | |
| rgbColor | setPaint() | [svg] SVGPaint | |
| iccColor | setPaint() | [svg] SVGPaint | |
| feature | hasFeature() | [dom] DOMImplementation | |
| version | hasFeature() | [dom] DOMImplementation | |
| qualifiedName | createDocumentType() | [dom] DOMImplementation | |
| publicId | createDocumentType() | [dom] DOMImplementation | |
| systemId | createDocumentType() | [dom] DOMImplementation | |
| namespaceURI | createDocument() | [dom] DOMImplementation | |
| qualifiedName | createDocument() | [dom] DOMImplementation | |
| tagName | createElement() | [dom] Document | |
| data | createTextNode() | [dom] Document | The string contents of the tex |
| data | createComment() | [dom] Document | |
| data | createCDATASection() | [dom] Document | |
| target | createProcessingInstruction() | [dom] Document | |
| data | createProcessingInstruction() | [dom] Document | |
| name | createAttribute() | [dom] Document | |
| name | createEntityReference() | [dom] Document | |
| tagname | getElementsByTagName() | [dom] Document | |
| namespaceURI | createElementNS() | [dom] Document | |
| qualifiedName | createElementNS() | [dom] Document | |
| namespaceURI | createAttributeNS() | [dom] Document | |
| qualifiedName | createAttributeNS() | [dom] Document | |
| namespaceURI | getElementsByTagNameNS() | [dom] Document | |
| localName | getElementsByTagNameNS() | [dom] Document | |
| elementId | getElementById() | [dom] Document | |
| feature | isSupported() | [dom] Node | |
| version | isSupported() | [dom] Node | |
| name | getNamedItem() | [dom] NamedNodeMap | |
| name | removeNamedItem() | [dom] NamedNodeMap | |
| namespaceURI | getNamedItemNS() | [dom] NamedNodeMap | |
| localName | getNamedItemNS() | [dom] NamedNodeMap | |
| namespaceURI | removeNamedItemNS() | [dom] NamedNodeMap | |
| localName | removeNamedItemNS() | [dom] NamedNodeMap | |
| arg | appendData() | [dom] CharacterData | |
| arg | insertData() | [dom] CharacterData | |
| arg | replaceData() | [dom] CharacterData | |
| name | getAttribute() | [dom] Element | |
| name | setAttribute() | [dom] Element | |
| value | setAttribute() | [dom] Element | |
| name | removeAttribute() | [dom] Element | |
| name | getAttributeNode() | [dom] Element | |
| name | getElementsByTagName() | [dom] Element | |
| namespaceURI | getAttributeNS() | [dom] Element | |
| localName | getAttributeNS() | [dom] Element | |
| namespaceURI | setAttributeNS() | [dom] Element | |
| qualifiedName | setAttributeNS() | [dom] Element | |
| value | setAttributeNS() | [dom] Element | |
| namespaceURI | removeAttributeNS() | [dom] Element | |
| localName | removeAttributeNS() | [dom] Element | |
| namespaceURI | getAttributeNodeNS() | [dom] Element | |
| localName | getAttributeNodeNS() | [dom] Element | |
| namespaceURI | getElementsByTagNameNS() | [dom] Element | |
| localName | getElementsByTagNameNS() | [dom] Element | |
| name | hasAttribute() | [dom] Element | |
| namespaceURI | hasAttributeNS() | [dom] Element | |
| localName | hasAttributeNS() | [dom] Element | |
| type | addEventListener() | [events] EventTarget | |
| type | removeEventListener() | [events] EventTarget | |
| eventTypeArg | initEvent() | [events] Event | Specifies the event type. This |
| eventType | createEvent() | [events] DocumentEvent | A string denoting the type of< |
| typeArg | initUIEvent() | [events] UIEvent | |
| typeArg | initMouseEvent() | [events] MouseEvent | |
| typeArg | initMutationEvent() | [events] MutationEvent | |
| prevValueArg | initMutationEvent() | [events] MutationEvent | |
| newValueArg | initMutationEvent() | [events] MutationEvent | |
| attrNameArg | initMutationEvent() | [events] MutationEvent | |
| oldMedium | deleteMedium() | [stylesheets] MediaList | |
| newMedium | appendMedium() | [stylesheets] MediaList | |
| rule | insertRule() | [css] CSSStyleSheet | |
| rule | insertRule() | [css] CSSMediaRule | |
| propertyName | getPropertyValue() | [css] CSSStyleDeclaration | |
| propertyName | getPropertyCSSValue() | [css] CSSStyleDeclaration | |
| propertyName | removeProperty() | [css] CSSStyleDeclaration | |
| propertyName | getPropertyPriority() | [css] CSSStyleDeclaration | |
| propertyName | setProperty() | [css] CSSStyleDeclaration | |
| value | setProperty() | [css] CSSStyleDeclaration | |
| priority | setProperty() | [css] CSSStyleDeclaration | |
| stringValue | setStringValue() | [css] CSSPrimitiveValue | |
| pseudoElt | getComputedStyle() | [css] ViewCSS | |
| pseudoElt | getOverrideStyle() | [css] DocumentCSS | |
| title | createCSSStyleSheet() | [css] DOMImplementationCSS | |
| media | createCSSStyleSheet() | [css] DOMImplementationCSS | |
| name | namedItem() | [html] HTMLCollection | |
| name | namedItem() | [html] HTMLOptionsCollection | |
| text | write() | [html] HTMLDocument | |
| text | writeln() | [html] HTMLDocument | |
| elementName | getElementsByName() | [html] HTMLDocument | |
| propertyOrMethodName | hasOwnProperty() | Object | The name of the property or me |
| propertyOrMethodName | propertyIsEnumerable() | Object | The name of the property or me |
| separator | join() | Array | The string to separate each el |
| string1 | concat() | String | The first string to append. |
| string2 | concat() | String | The second string to append. |
| ... | concat() | String | etc. |
| searchString | indexOf() | String | The substring to search for wi |
| searchString | lastIndexOf() | String | The substring to search for wi |
| compareString | localeCompare() | String | The string to compare to the c |
| str | eval() | Global | The string to evaluate. |
| string | parseInt() | Global | The string to convert to a num |
| string | parseFloat() | Global | The string to convert to a num |
| dateString | parse() | Date | The string to parse as a date; |
| sourceString | exec() | RegExp | The string to run the regular< |
| sourceString | test() | RegExp | The string to run the regular< |
| str | decode() | [pshop] Folder | The string to decode. |
| str | decode() | [pshop] File | The string to decode. |
| str | encode() | [pshop] Folder | The string to encode. |
| str | encode() | [pshop] File | The string to encode. |
| str1 | write() | [pshop] File | The first string to write. |
| str2 | write() | [pshop] File | Additional string(s) to write. |
| ... | write() | [pshop] File | |
| str1 | writeln() | [pshop] File | The first string to write. |
| str2 | writeln() | [pshop] File | Additional string(s) to write. |
| ... | writeln() | [pshop] File | |
| basePath | getRelativeURI() | [pshop] File | The path to calculate relative |
| newName | rename() | [pshop] File | The new name for the file. |
| msg | alert() | [pshop] Application | The message to display. |
| charID | charIDToTypeID() | [pshop] Application | |
| msg | confirm() | [pshop] Application | The confirmation message to di |
| action | doAction() | [pshop] Application | |
| from | doAction() | [pshop] Application | |
| stringID | stringIDToTypeID() | [pshop] Application | |
| value | putString() | [pshop] ActionDescriptor | |
| value | putString() | [pshop] ActionList | |
| value | putName() | [pshop] ActionReference | |
| styleName | applyStyle() | [pshop] ArtLayer | |
| destinationProfile | convertProfile() | [pshop] Document | |
| printSpace | print() | [pshop] Document | |
| name | add() | [pshop] Documents | |
| basePath | getRelativeURI() | [pshop] Folder | The path to calculate relative |
| newName | rename() | [pshop] Folder | The new name for the folder. |
| mask | getFiles() | [pshop] Folder | The search mask to use. |
| mode | open() | [pshop] File | One of 'r',
|
| type | open() | [pshop] File | Four character MacOS file type |
| creator | open() | [pshop] File | Four character MacOS creator t |
| oldMaterialName | swapMaterial() | [anark] Model | The name of the old material.< |
| timeContextName | getContext() | [anark] Presentation | Variable name of the TimeConte |
| commandLine | launch() | [anark] Container | Application and file to launch |