Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is this thing in JavaScript?

var something = {

wtf: null,
omg: null
};

My JavaScript knowledge is still horribly patchy since I last programmed with it, but I think I've relearned most of it now. Except for this. I don't recall ever seeing this before. What is it? And where can I learn more about it?

like image 381
Daddy Warbox Avatar asked Oct 07 '08 15:10

Daddy Warbox


1 Answers

It's object literal syntax. The 'wft' and 'omg' are property names while, null and null are the property values.

It is equivalent to:

var something = new Object();
something.wtf = null;
something.omg = null;

Check out mozilla's documentation on object literals: http://developer.mozilla.org/En/Core_JavaScript_1.5_Guide:Literals#Object_Literals

like image 117
Aaron Maenpaa Avatar answered Sep 21 '22 06:09

Aaron Maenpaa