It turns the variable o into an object containing one property ( x ), and sets the value of this property to 1.
Edit
To be clear, as you have demonstrated, you do not need to add properties this way. You can create a property on an object by simply assigning it ( oy = "Awesomesauce" )
Regarding your related question; {x:1, y:2} is just an object literal with two properties x and y with values ββ1 and 2 respectively. working on this object is literally like working on a primitive value of values ββ( console.log("my,string".split(",")) ).
"[object Object]" is how a non-specifically typed object is represented in string form.
Edit 2
According to your comment: the lowercase "object" is a type. typeof o will give an object . The object (capital "O") is just a string representation of {x:1} . The string representation of an array or number is smart because it knows the type more accurately. Using a special object such as o , it simply is a shared object and thus writes: object (the type) Object (a string representation of o itself)
source share