Availability: |
| ||||||||
JavaScript syntax: | - | myString = new String() | |||||||
- | myString = String | ||||||||
Object properties: | constructor, length, prototype | ||||||||
Class methods: | fromCharCode() | ||||||||
Object methods: | anchor(), big(), blink(), bold(), charAt(), charCodeAt(), concat(), fixed(), fontcolor(), fontsize(), fromCharCode(), indexOf(), italics(), lastIndexOf(), link(), localeCompare(), match(), replace(), search(), slice(), small(), split(), strike(), sub(), substr(), substring(), sup(), toLocaleLowerCase(), toLocaleUpperCase(), toLowerCase(), toSource(), toString(), toUpperCase(), valueOf() |
An instance of the class "String" is created by using the new operator on the String() constructor. The new object adopts the behavior of the built-in prototype object through the prototype-inheritance mechanisms.
All properties and methods of the prototype are available as if they were part of the instance.
A String object is a member of the type Object.
Cloning the built-in String object creates new String objects. This is done by calling the String constructor with the new operator being applied to an existing String object, thus:
myString = new String("a string of text");
A String object can be coerced to a string value and can be used anywhere where a string value would be expected.
Programmers familiar with object oriented techniques may prefer to use the String object while procedural language programmers may implement the same functionality with a string value instead.
This is an example of the flexibility of JavaScript in its ability to accommodate a variety of users from different backgrounds.
The prototype for the String prototype object is the Object prototype object.
In Netscape Navigator, you can traverse a string as if it were an array and access characters individually by their index position in the array. This doesn't work in MSIE.
Property | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
constructor | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
length | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | ReadOnly, DontDelete, DontEnum. |
prototype | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | 3.0 ![]() | 3.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
Method | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
---|---|---|---|---|---|---|---|---|---|---|---|
anchor() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
big() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
blink() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
bold() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
charAt() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
charCodeAt() | 1.2 ![]() | 5.5 ![]() | 4.0 ![]() | 5.5 ![]() | 3.0 ![]() | 3.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | ![]() |
concat() | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | 3.0 ![]() | 3 ![]() | ![]() | ![]() | ![]() | - |
fixed() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
fontcolor() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
fontsize() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
fromCharCode() | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | 3.0 ![]() | 3.0 ![]() | 3 ![]() | ![]() | ![]() | ![]() | - |
indexOf() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
italics() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
lastIndexOf() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
link() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
localeCompare() | 1.5 ![]() | 5.5 ![]() | 6.0 ![]() | 5.5 ![]() | ![]() | ![]() | 3 ![]() | ![]() | ![]() | ![]() | - |
match() | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | 3 ![]() | ![]() | ![]() | ![]() | ![]() |
replace() | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | 3 ![]() | ![]() | ![]() | ![]() | ![]() |
search() | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | ![]() | 3 ![]() | ![]() | ![]() | ![]() | ![]() |
slice() | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | 2.0 ![]() | 3 ![]() | ![]() | ![]() | ![]() | - |
small() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
split() | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
strike() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
sub() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
substr() | 1.2 ![]() | 3.0 ![]() | 4.0 ![]() | 4.0 ![]() | ![]() | 3.0 ![]() | 3 ![]() | ![]() | ![]() | ![]() | - |
substring() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
sup() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | Deprecated |
toLocaleLowerCase() | 1.5 ![]() | 5.5 ![]() | 6.0 ![]() | 5.5 ![]() | 3.0 ![]() | 2.0 ![]() | 3 ![]() | ![]() | ![]() | ![]() | - |
toLocaleUpperCase() | 1.5 ![]() | 5.5 ![]() | 6.0 ![]() | 5.5 ![]() | 3.0 ![]() | 2.0 ![]() | 3 ![]() | ![]() | ![]() | ![]() | - |
toLowerCase() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
toSource() | 1.3 ![]() | 3.0 ![]() | 4.06 ![]() | 4.0 ![]() | ![]() | ![]() | 3 ![]() | ![]() | ![]() | ![]() | - |
toString() | 1.3 ![]() | 1.0 ![]() | 4.06 ![]() | 3.02 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
toUpperCase() | 1.0 ![]() | 1.0 ![]() | 2.0 ![]() | 3.02 ![]() | 3.0 ![]() | 2.0 ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
valueOf() | 1.1 ![]() | 3.0 ![]() | 3.0 ![]() | 4.0 ![]() | ![]() | ![]() | 2 ![]() | ![]() | ![]() | ![]() | - |
ECMA 262 edition 2 - section - 4.3.18
ECMA 262 edition 2 - section - 10.1.5
ECMA 262 edition 2 - section - 15.5
ECMA 262 edition 3 - section - 4.3.18
ECMA 262 edition 3 - section - 15.5
Wrox Instant JavaScript - page - 33
Prev | Home | Next |
String literal | Up | String() constructor |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |