slice() array in javascript
Return the selected value from array, we can select the array value by using index. If the specified index value is out of range then it will return the -1.
slice() method for string values
Syntax
endindex is the optional.
Example :
Example Program:- (Editor)
Editor is Loading...
Advertisement
slice() method for string values
Syntax
string.slice(startindex[,endindex]);
endindex is the optional.
Example :
var fruits = ["Jan", "Feb", "Mar", "Apr", "May"];
alert(fruits.slice(1)); //return 2 to 5th value (Not removed)
alert(fruits.slice(2,4)); //return 3 to 4th value
Example Program:- (Editor)
Editor is Loading...
Advertisement
Nhận xét
Đăng nhận xét