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

Nhận xét

Bài đăng phổ biến từ blog này

Tourist places in kk district:1) Thiruvalluvar statue

How to set multiple images in a loop javascript?

Variable in CSS