Inspired
Monday, September 26, 2011
Best way to check for an empty string in JavaScript
For checking if a string is empty, null or undefined use:
function isEmpty(str){ return (!str || 0===str.length); }
For checking if a string is blank (with no tabs and spaces):
if(str.replace(/\s/g,"") == ""){ }
Newer Post
Older Post
Home