O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Objects

JavaScript can be used to define objects. These objects act like classes in that they contain properties and methods. Like other languages, you use objects in JavaScript to make your code more readable, easier to understand, and thus more maintainable. There are two primary ways to create objects in JavaScript: using the literal notation, and using the object construction notation. Let’s look at each.

Literal Notation

You create an object using the literal notation by assigning a variable as the object name and then using brackets to contain the properties and method for the object. Each property and method is defined using a colon and separated by a comma. The methods are defined as a function. The following shows an object created ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required