isNullOrEmpty

June 30, 2009 at 12:12 pm Leave a comment

Coding a lot in JavaScript i often have to check if an object is

undefined, null or at least an empty string.

So it would be great to have a method like in C#

string.isNullOrEmpty()

This is my solution for JavaScript:

window.isNullOrEmpty = function(obj) {
return (obj === '' || obj === null || obj === undefined)
}

And the best of it: it does not only work on strings like in C#, it works for every object.

Attatching the method to the window object makes it purely available from everywhere.

Entry filed under: javascript. Tags: .

<title /> vs <title></title> slider with not linear values

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Calendar

June 2009
M T W T F S S
« May   Jul »
1234567
891011121314
15161718192021
22232425262728
2930  

Most Recent Posts


Follow

Get every new post delivered to your Inbox.