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

Example for Conditional Operator in php

16-04-2017 php Conditional Operator example

How to insert bulk information into database in single query execution

18-03-2017 insert sql bulk database

How to find Angular Errors

06-03-2017 errors angularjs exceptionHandler

Call a function every second or 5 seconds in javascript

22-02-2017 setinterval function calling