next up previous contents
Next: split Up: Methods Previous: lastIndexOf   Contents


slice

Description
Returns a section of a string.


Syntax

  1. StringObj.slice(start, [end])
  2. "String Literal".slice(start, [end])


Parameters

start
A number specifying the index of the starting point for the slice. If start is a negative number, the starting point is determined from the end of the string, where -1 is the last character.
end
Optional. A number specifying the index of the ending point for the slice. If end is not specified, the slice includes all characters from start to the end of the string. If end is a negative number, the ending point is determined from the end of the string, where -1 is the last character.


Returns

The slice method returns a String object containing the specified portion of stringObj without modifying the original String object. The returned string includes the start character and all characters up to (but not including) the end character.


Example

s = "This is an example of String.slice";
r = s.slice(5, 7);
trace(r);
//output: is




Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.