Javascript Notes – Objects

Basic Syntax

Objects are similar to arrays in the sense that they store data. However Objects use key value pairs and are better suited for many types of data. Here is a sample of a simple object:

A key difference between objects and arrays, is that items in objects have no order. The data must be retrieved by using the key.

Retrieving Data

So why would anyone ever use the bracket notation when dot notation is so much simpler. Well there are some notable exceptions where dot notation will not work.

Updating Object Data

This is very similar to updating array data. For objects you simply access a property and then reassign it.

+ There are no comments

Add yours