Remove last two characters from given string

substring
javascript
remove

If we want to remove last two characters from given string. There is an simple method in javascript, i.e substring.

var name = "hi hellow";
name.substring(0, name.length - 2);

the result is : hi hell

Note: The substring() method does not change the original string.

The actual substring syntx is 

string.substring(start, end)

 

You might also like:

Check null values in JavaScript?

04-02-2019 JavaScript null check null value

Convert and download html to pdf without saving file

28-10-2018 node js convert html to pdf pdf download pdf without saving

How to use request module in node js

16-03-2017 request module node js

Sanitization in java sript

14-03-2017 sanitization java script

How to get current date and time (yyyy-mm-dd H:i:s) using javascript

09-03-2017 javascript date time