Thursday 24 February 2011

The "in" operator

Did you know that there is a in operator in JavaScript? 
This operator checks if a key exists in an object and it can be used very simple like below:
var o = { 8:2008, 9:2009, 10:2010 };
8 in o; // true, key 8 exists with a value of 2008
1 in o; // false, the key 1 does not exist in o

No comments:

Post a Comment