TIL 20: javascript 6

Standard

Objects (continued):

  • Objects can be thought of as key/value storage, like a dictionary
  • Objects can be used to store data as lookup tables

code

  • check if an object property exists with .hasOwnProperty(propertyName); which returns true or false
  • a javascript object is one way to handle flexible data, allowing for artbitrary combinations of different data types
  • complex data structures might be stored as objects inside an array
  • objects properties are key-value pairs, e.g. “artist”: “Beatles” is a property with key “artist” and value “Beatles”
  • objects can be nested e.g.

code

  • access the sub-properties of nested objects by chaining the dot or bracket notation, as shown above
  • nested arrays are accessed in a similar manner, e.g. arr1[1].arr2[0];
  • JSON (JavaScript Object Notation) is a related data interchange format used to store data.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s