String.slice() (Method)

Returns a sub-string sliced out of the original.


ECMAScript edition - 3
JavaScript - 1.2
JScript - 3.0
Internet Explorer - 4.0
Netscape - 4.0
Netscape Enterprise server - 2.0
Property/method value type:String primitive
JavaScript syntax:-myString.slice(startPos)
-myString.slice(startPos, endPos)
Argument list:endPosThe ending character position
startPosThe starting character position

The sub-string is identified using the parameters passed as arguments in the method call.

The second argument is optional. If it is missing then it is assumed to mean the end of the string.

Example code:

   myIndex = myString.lastIndexOf("AAA");
   document.write(myString.slice(myIndex, myIndex+4));

See also:String.split(), String.substr(), String.substring()

insert figure 0094


ECMA 262 edition 3 - section -