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 |
How to get id by using name attribute in javascript20-03-2017 html id name javascript |
How to convert html to pdf in Node js12-03-2017 pdf convert html node js |
Navigate to another page using java script06-03-2017 javascript redirection navigation |
Filters for convert text to camel case in Angular Js05-03-2017 angularjs camelcase filters |