javascript interactive

JavaScript Interactive — a console crash course

4.1 Simple Objects

Warning: Your browser may be outdated or unsupported.

The JavaScript console is known to display some of the examples incorrectly in Internet Explorer 8 or older.
var obj = { a: 'value', b: 123, c: null }

Object instances are basically ordered hash sets of named values (properties). See 1.2 Object Types for the built-in objects.
["a", "b", "c"]
Property names can be listed with the built-in Object.keys() function. See also 2.3 Loops & Iteration for iteration over object properties.
Property value access is an O(1) operation, making any object a candidate lookup table. See 2.5 Property Access for alternative syntax and details.
function toString() {
    [native code]
All objects also have built-in non-enumerable properties that can only be accessed directly. See the Mozilla JavaScript Reference for a list of these, such as toString, valueOf, hasOwnProperty.
"[object Object]"
The built-in toString() method works for all objects. But the default implementation isn't all that exciting.
{ a: 1 } === { a: 1 }
Also worth noting is that object instances are never equal unless it is actually the same instance.

Index 1 2 3 4 5 6 7 8