Checking for object literals

by Pascal Opitz

published 3 October 2006

Such a basic thing to do, but still, I didn’t have to do it until now:
Checking if an object literal is defined.


var my_object_literal
{
  'my_property' : 'I exist'
};

if (window.my_object_literal)
{
   alert(my_object_literal.my_property);
}

via FAQTS

Comment

Have your say

If your comment doesn't show up straight away, please don't be offended - we're not censoring, we are just trying to keep out all the viagra and poker ads. Thanks to an explosion of spam all comments are held for manual green-lighting.

name Remember
email
http://
Message <?>

Quick links

Other people's articles that we think you might be interested in: