Console Learner — An interactive JavaScript course.


4.1 Plain Objects

>>>
var obj = { a: 'value', b: 123, c: null }

  
Object instances are basically ordered sets of named values (properties). See 1.2 Object Types for some common built-in object types.
>>>
Object.keys(obj)
["a", "b", "c"]
Property names can be listed with the built-in Object.keys() function. See also 2.6 Loops & Iteration for iteration over object properties.
>>>
obj.a
"value"
Property access is an O(1) (constant time) operation, making any object a candidate lookup table. See 2.2 Property Access for details.
>>>
obj.toString
function toString() {
    [native code]
}
All objects also have some built-in non-enumerable properties, such as toString, valueOf and hasOwnProperty. These typically contain functions that operate on the object, also known as methods. See the Object instance properties for a compete list.
>>>
obj.toString()
"[object Object]"
The built-in toString() method works for all objects. But the default implementation isn't all that exciting.
>>>
{ a: 1 } === { a: 1 }
false
Also worth noting is that object instances are never equal unless it is actually the same instance.
>>>

The console allows you to interact with the course material and examples. Use the following keys:

A special logging function is also available:


Need more magic? Check out the other developer tools on this site.