Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Creating JS Objects

Objects are one of the 7 standard JS Data types and are heavily used to store multiple variables together. Objects are comprised from a set of key value pairs (syntax-wise like CSS). The key acts like a placeholder and the value is as usually the value this variable contains.

In the example above we have created an object to store information in one place, where otherwise we would have needed multiple variables. This object now holds information about a person. The pieces of information are the keys (or object's properties) and the values can be any JS data type (even other objects as we will see later on).

In order to access a specific piece of info now we need to console.log(jake.firstName) etc.

 

 

Object Literal

Kostas Diakogiannis
Module by Kostas Diakogiannis, updated more than 1 year ago
No tags specified