Content with Style

Web Technique

Checking for object literals

by Pascal Opitz on October 3 2006, 07:46

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