Objects
In javascript the objects are mutable because we change the values pointed by the reference object, instead, when we change a primitive value we are changing its reference which now is pointing to the new value and so primitive are immutable. The primitive types of JavaScript are true
, false
, numbers, strings, null
and undefined
. Every other value is an object
.
In JavaScript objects contain propertyName
: propertyValue
pairs. There are three ways to create an object
in JavaScript:
literal
Note: this is the recommended way.
object-oriented
Note: it's almost like Java.
and using
object.create
Note: it creates a new object with the specified prototype object and properties.
Last updated
Was this helpful?