The basic syntax for the slice is
array.slice(start, end)
The sample string is
var text = "welcome!";
Now, i am trying to remove last character from the above string using slice.
text = text.slice(',',-1);
Now the result is : welcome
Slice is also used for remove values from array, here is the example.
var fruits = ["Orange", "Strawberry", "Banana", "Orange", "Mango"]; var myBest = fruits.slice(-3, -1);
the result is
Orange,Lemon
You might also like:
Convert and download html to pdf without saving file28-10-2018 node js convert html to pdf pdf download pdf without saving |
How to use request module in node js16-03-2017 request module node js |
How to find Angular Errors06-03-2017 errors angularjs exceptionHandler |
Filter for replace text in Angular Js05-03-2017 filter replace angular js |
Send Mail in Node Js21-02-2017 node js mail npm module |