October 2014
Intermediate to advanced
218 pages
4h 38m
English
JavaScript objects are very simple collections of name-value pairs. There are two ways of creating a simple object in JavaScript. The first way is as follows:
var obj = new Object();
And the second way is as follows:
var obj = {};We can also create an object entirely as follows:
obj = {
name: {
first: 'Gandalf',
last: 'the Grey'
},
address: 'Middle Earth'
};In object-oriented programming (OOP), an object is an instance of a class. A class defines the characteristics of the object. For our algorithms and data structures, we will create some classes that will represent them. This is how we can declare a class that represents a book:
function Book(title, pages, isbn){ this.title = title; this.pages = pages; this.isbn = isbn; ...Read now
Unlock full access