slice() string in javascript

          Return the selected value from string, we can select the string value by using index. If the specified index value is outof range then it will return the -1.
slice() method for array values


Syntax

     string.slice(startindex[,endindex]);

 endindex is the optional.

Example

str="Merbin joe" ;



alert(str.slice(3));   //return from 3rd character ["bin joe"]

alert(str.slice(3,5)); //return 3 to 5th character ["bi"]

Example Program:- (Editor)


Editor is Loading...

Advertisement

0 nhận xét:

Đăng nhận xét