Using slice remove last two characters from given string

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:

File Upload Using Angular Js and Node Js

28-05-2018 AngularJs Node js file upload multer module

How to submit form using javascript or jquery.

16-04-2017 javascript jquery submit form

Sanitization in java sript

14-03-2017 sanitization java script

How to make an http request in node js

14-03-2017 http module node js

Call a function every second or 5 seconds in javascript

22-02-2017 setinterval function calling