Using slice remove last two characters from given string

07-03-2017 slice remove

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:

How to upload file by using request module
18-03-2017 request module node js
Filter for insert HTML in Angular Js
06-03-2017 filter show html angular js html
Filters for convert text to camel case in Angular Js
05-03-2017 angularjs camelcase filters
How to remove last / value from url in javascript
27-02-2017 array javascript last value
Send Mail in Node Js
21-02-2017 node js mail npm module