# JavaScript objects

So far, we have:

* done some stuff with basic data values called [primitives](http://joncoded.hashnode.dev/javascript-primitives)
    
* assigned those primitives to locations called [variables](https://joncoded.hashnode.dev/javascript-variables)
    
* done things to those variables with [operators](https://joncoded.hashnode.dev/javascript-operators)
    
* done even more things to variables with functions
    

Now, we take it to another level with **objects:**

* which encapsulate data in pairs called **keys** and **values**
    
    * the key acts as a sign of meaning for the value
        
    * the value can be a *primitive*, another *object* or even a *function*
        

```javascript
const emptyObject = {}

const oneKeyObject = {
    name: "Jon"
}

const complexObject = {
    key1 : "Hello",
    key2 : "Hey", 
    anotherKey : 42, 
    someOtherKey : true, 
    nestedObject : { 
        nestedObjectKey: true
    },
    method: function () {
        return "Surprise!"
    }
}
```

We can gather from the above that:

* the object has keys separated by commas
    
* keys can have names similar to variables
    
    * but with no declaration keywords (i.e. `const`, `let`,`var`)
        

More abstractly:

```javascript
keyword anObject = {
    aKey1 : aValue1, 
    aKey2 : aValue2,
    ...
}
```

Recall that objects **copy by reference**:

* when we copy an object and we change the original...
    
    * ... we also make the same changes in the copy!
        
    * ... because variables store *references to the* object
        
        * ...and *not the object* itself
            

In other words, it resembles updating a blog post: if you edit the original, everyone who calls it up will receive the updates!
