Using Object Syntax

To use objects in JavaScript effectively, you need to have an understanding of their structure and syntax. An object is really just a container to group together multiple values and, in some instances, functions. The values of an object are called properties and the values of functions are called methods.

To use a JavaScript object, you must first create an instance of the object. You create object instances by using the new keyword with the object constructor name. For example, to create a Number object, you could use the following line of code:

var x = new Number("5");

Object syntax is very straightforward: You use the object name and then a dot and then the property or method name. For example, the following lines of code ...

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.