‘IsNullOrWhitespace’ in JavaScript?
For a succinct modern cross-browser implementation, just do: function isNullOrWhitespace( input ) { return !input || !input.trim(); } Here’s the jsFiddle. Notes below. The currently accepted answer can be simplified to: function isNullOrWhitespace( input ) { return (typeof input === ‘undefined’ || input == null) || input.replace(/\s/g, ”).length < 1; } And leveraging falsiness, even … Read more