Remove last two characters from given string using slice

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 




You might also like:

How to redirect one page to another page in php
20-03-2017 redirect php
How to use http-post request in node js
14-03-2017 http-post module node js
How to make an http request in node js
14-03-2017 http module node js
Filter for change Date format (MM-dd-yyyy) in Angular Js
05-03-2017 mm-dd-yyyy date formats angular js
How to get drop down value when drop down change using javascript
27-02-2017 onchange events dropdown javascript functions