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

     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

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

How to set the SDK, NDK and JDK path to android studio?

physicsjs - Increase the restitution value for circle and retangle

Select all values from list box in a single click using javascript