html – What is the Difference Between Whitespace and Empty String in JavaScript

html – What is the Difference Between Whitespace and Empty String in JavaScript

First you should know the difference between empty string and a white space.

The length of a white space is 1 .

An empty string will have a length zero.

If you need to remove any number of white spaces at both starting and ending of a string you may use trim() function, then you may count the length if it is necessary.

OR

You may check for empty string after using trim()

html – What is the Difference Between Whitespace and Empty String in JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *