Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Mastering JavaScript Object-Oriented Programming
Mastering JavaScript Object-Oriented Programming

Mastering JavaScript Object-Oriented Programming: Advanced patterns, faster techniques, higher quality code

Arrow left icon
Profile Icon Andrea Chiarelli
Arrow right icon
R$50 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7 (6 Ratings)
Paperback Jun 2016 292 pages 1st Edition
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m
Arrow left icon
Profile Icon Andrea Chiarelli
Arrow right icon
R$50 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7 (6 Ratings)
Paperback Jun 2016 292 pages 1st Edition
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m
eBook
R$80 R$218.99
Paperback
R$272.99
Subscription
Free Trial
Renews at R$50p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Mastering JavaScript Object-Oriented Programming

Chapter 1. A Refresher of Objects

Any JavaScript programmer knows that almost everything in this scripting language is an object—from arrays to functions, from regular expressions to dates. We can say that what is not a primitive data type is an object. But, even the primitive data types such as numbers or strings have object wrappers, that is, they are accessible via objects. So, we can argue that objects are vital in JavaScript, and we need to learn the use of objects as best as we can in order to create better applications. One way, for example, to better use objects is applying the Object-Oriented Programming (OOP) paradigm.

However, before diving into principles and pattern of this programming approach, let's start this first chapter with a quick recap about objects fundamentals. In particular, the chapter will discuss:

  • How to create and manage literal objects
  • How to define object constructors
  • What a prototype is and how to use it
  • The new ECMAScript 2015 class construct and its relation to objects, constructors, and prototypes

Object literals

An object is a container of values combined to form a single data structure that has a particular identity. Normally, in fact, an object is used to represent a specific entity such as a person, an order, an invoice, a reservation, and so on, through an aggregation of data and functionalities.

The data is called properties and are represented by pairs of names and values. The functionalities are usually called methods and are represented by functions, even if they are nothing more than the same pairs of names and values as for properties, where values happen to be functions.

The simplest way to create an object in JavaScript is the literal representation, as shown in the following example:

var emptyObject = {}; 
var person = {"name": "John", "surname": "Smith"}; 

Through the literal notation, we represent an object by enclosing its properties and methods in braces. In the first statement, we created an empty object, an object without properties nor methods; all in all, not very useful but important to understand that an object is basically a list of pairs of values and, as with every list, it can be empty.

In the second declaration, in order to define the object person, we listed two pairs of strings separated by commas. Each pair consists of two strings separated by a colon. The first string is the name of the property while the second one represents its value.

Properties

To assign a name to the properties of an object, we don't have the same restrictions as for the JavaScript variable names. We can use any string, even if there is some constraint when accessing properties with particular names, as we are going to see.

The double or single quotes around the property name are generally optional, but they are required when the name does not follow the rules for variable names. So, we could write our definition of person as follows:

var person = {name: "John", surname: "Smith"}; 

But if we want a definition like the following, we are forced to use double or single quotes:

var person = {"first-name": "John", "second-name": "Smith"}; 

We can assign any value to an object property and any JavaScript expression, including another object. So, we can create nested objects as shown here:

var person = {name: "John", 
               surname: "Smith", 
               address: { 
                 street: "13 Duncannon Street", 
                 city: "London", 
                 country: "United Kingdom" 
               }}; 

As we can see, an object with its specific properties is assigned to the address property.

To access the values stored in an object property, we have two approaches. The first approach is the so-called dot-notation, by which we indicate an object and the property we're interested in, separated by a point:

var name = person.name; 

This is usually the most used approach because it is more compact and quite familiar to developers who have worked with other programming languages.

Using the second approach, we specify the properties of an object by indicating its name as a string in square brackets:

var name = person["name"]; 

This approach is mandatory when the property name does not follow the rules for JavaScript's variable names. For example, we cannot use the dot-notation to access a property named first-name.

If we try to access a non-existing property of an object, an error is not generated but returns the undefined value. In the following example, therefore, the age variable will get the undefined value:

var age = person.age; 

If we try to assign a value to a not yet defined property, we actually create this property initializing it with the assigned value:

person.age = 28; 

This example shows us the dynamic nature of JavaScript objects. The object's structure is very flexible and can be changed dynamically during the execution of a script. This feature gives us an alternative way for the creation of an object based on a kind of incremental definition. In practice, instead of completely defining a literal representation of our object, we can start from a basic representation and gradually enrich it with the properties we want. Following this approach, we can define our object person as follows:

var person = {}; 
person.name = "John"; 
person.surname = "Smith"; 
person.address = { 
                   street: "123 Duncannon Street", 
                   city: "London", 
                   country: "United Kingdom" 
                 }; 
person.age = 28; 

Besides being able to dynamically create the properties of an object, we can also destroy them at runtime using the delete statement. The following example shows how to remove the address property from our person object:

delete person.address; 

After the removal of the address property, any attempt to access it will return the value undefined.

Methods

While object properties represent data, methods represent actions that an object can perform. From a syntactical point of view, the definition of an object's method is quite similar to the definition of a property. Here's an example:

function showFullName() { 
  return "John Smith"; 
} 
 
person.fullName = showFullName; 

We can also assign a method to an object inside its literal representation as shown here:

var person = {name: "John", 
        surname: "Smith", 
        showFullName: function() { 
          return "John Smith"; 
        } 
}; 

ECMAScript 2015 allows us to define methods in literal notation in a more direct form, as in the following example:

var person = {name: "John", 
        surname: "Smith", 
        showFullName() { 
          return "John Smith"; 
        } 
}; 

Actually, the distinction between properties and methods is somewhat artificial in JavaScript. In fact, since the functions are also objects, a method is nothing more than a property that has been assigned a function.

Incidentally, since the value assigned to a property can change at runtime, it is possible that a property, which was initially assigned a function, can then be assigned a different value, such as a string or a number. Unlike other programming languages, a method is not a stable condition for a member of an object, it is not a characteristic of a specific property. We can simply affirm that a property is a method when it has a function assigned, but it is a dynamic condition.

In the previous example, we defined a function that simply returns a string and we assigned that function name to a new property of the person object. Note that we are not assigning the result of the function call to the property, but the function itself by means of its name.

The fullName property, since it has been assigned a function, is actually a method. To run it, we must refer to it by specifying parentheses as in a usual function call:

var nameAndSurname = person.fullName(); 

Of course, we can assign an anonymous function to a property directly as in the following example:

person.fullname = function () { 
  return "John Smith"; 
} 

The method that we just defined in the example is not so useful. It always displays the same string even if we assign a different value to name and surname of the person object. It would be useful to have a way to display the current value of the corresponding properties.

JavaScript allows us to reach this goal through the this keyword. The keyword represents the object when the method is invoked. So, we can rewrite our method in the following way:

person.fullName = function () { 
  return this.name + " " + this.surname; 
}; 

This guarantees the correct display of the current data at the time of the call.

Object constructors

The creation of an object, as we have seen in the examples, is quite straightforward using the literal notation. We do not have to define a class, but we directly create the object just when we need it, and hopefully we can change its structure during the execution of our script.

Suppose, we need multiple objects of the same type, for example more person objects, which share the same structure.

Using the literal notation, we will have to repeat the definition for each object that we want to create, which is essential to identify the single person but unnecessarily repetitive for constant members such as the methods. In other words, using the literal notation in the definition of the objects, we get a non reusable result. For example, if we want to create two person objects, we need to write the following code:

var johnSmith = {name: "John", 
                  surname: "Smith", 
                  address: { 
                    street: "13 Duncannon Street", 
                    city: "London", 
                    country: "United Kingdom" 
                  }, 
                  displayFullName = function() { 
                    return this.name + " " + this.surname; 
                  } 
                }; 
var marioRossi = {name: "Mario", 
                   surname: "Rossi", 
                   address: { 
                     street: "Piazza Colonna 370", 
                     city: "Roma", 
                     country: "Italy" 
                   }, 
                   displayFullName = function() { 
                     return this.name + " " + this.surname; 
                   } 
                 }; 

Therefore, in order to avoid defining from scratch objects that have the same structure, we can use a constructor—a JavaScript function invoked using the new operator. Let's see how to create a constructor for the person object with an example:

function Person() { 
  this.name = ""; 
  this.surname = ""; 
  this.address = ""; 
  this.email = ""; 
 
  this.displayFullName = function() {...}; 
 
} 

This function defines the properties of our object by assigning them to the this keyword and setting default values. Even if this constructor may seem useless since it assigns just empty strings to the properties, it defines a common structure to any object created by it. So, in order to create an object of type person, we will have to call the function by prefixing the new operator:

var johnSmith = new Person(); 
johnSmith.name = "John"; 
johnSmith.surname = "Smith"; 
 
var marioRossi = new Person(); 
marioRossi.name = "Mario"; 
marioRossi.surname = "Rossi"; 

In this way, when we want to create multiple objects with the same structure, we will limit ourselves to just set the specific values that distinguish one object from another.

As you can see, the name given to the constructor is capitalized. This is not a requirement for JavaScript, but a common convention that helps to distinguish regular functions from constructors.

In the definition of a constructor, we can expect the presence of parameters that can be used in the initialization of our object. For example, consider the following definition of the constructor of the person object:

function Person(name, surname) { 
  this.name = name; 
  this.surname = surname; 
  this.address = ""; 
  this.email = ""; 
  this.displayFullName = function() {...}; 
} 

It allows us to create and initialize an object by specifying values directly in the constructor call, as in the following example:

var johnSmith = new Persona("John", "Smith"); 
var marioRossi = new Persona("Mario", "Rossi"); 

It is very important to use the new operator while creating an object through a constructor. In fact, if we forget it, what we get is not the creation of an object, but the execution of the function, with unpredictable results. For example, suppose that we try to create a person object omitting the new operator:

var johnSmith = Person(); 

The value of the variable johnSmith will be undefined, since the function Person() returns no value. In addition, all the properties and methods defined within the body of the function will be assigned to the object represented by this keyword in the execution context of the function, as can be for example the global object window in a browser. This assignment could redefine the value of variables with the same name causing side effects that are difficult to predict and to debug.

We can reduce the risk of such oversights by resorting to the use of strict mode:

function Person() { 
  "use strict"; 
  ... 
} 

In strict mode, the value of the object represented by the this keyword is undefined during the execution of the function. This generates a runtime error while trying to access the property of an object that does not exist, thus avoiding unwanted invocations of the constructor.

Unfortunately, this approach is not sufficient when the constructor is defined inside a namespace:

var mankind = { 
  ... 
  Person: function(name, surname) { 
    'use strict'; 
    this.name = name; 
    this.surname = surname; 
    ... 
  } 
}; 
 
var johnSmith = mankind.Person("John", "Smith"); 

In this case, the this keyword represents the mankind object, so we will not have a runtime error that warns us of the incorrect use of the constructor, but the properties name and surname will be attached to the mankind object.

The Object() constructor

We have seen how the use of a constructor offers us a higher level of abstraction in the creation of objects. In this section, we explore a particular constructor provided to us by JavaScript—the Object() constructor.

This constructor allows us to create a generic object, as shown in the following example:

var person = new Object(); 
person.name = "John"; 
person.surname = "Smith"; 

Here, we use the new operator to create a new instance of an empty object and then we create properties by assigning values, as in the literal approach.

Actually, creating an object using the literal notation or creating it by means of the Object() constructor is the same thing. Every object created using the literal notation has Object() as its implicit constructor. We can realize it by accessing the constructor property that every object has the following:

var person = {}; 
console.log(person.constructor == Object);  //result: true 

The Object() constructor is also able to generate object instances from any JavaScript expression, as shown by the following code:

var number = new Object(12); 
var anotherNumber = new Object(3*2); 
var string = new Object("test"); 
var person = new Object({name: "John", surname: "Smith"}); 

Apart from the last statement, which is equivalent to the creation of an object via its literal representation, the first three statements create an object from a primitive data type, such as a number or string. The result is not just a numerical value or a string value, but built-in objects specialized in handling numeric values and strings.

We will return later in the book on the Object() constructor for use in advanced mode.

Object prototypes

The flexibility of JavaScript objects is expressed primarily through the possibility of changing their structure even after their creation. Even while using a constructor to create an object, we continue to have this possibility. For example, you can write the following code:

var johnSmith = new Person("John", "Smith"); 
var marioRossi = new Person("Mario", "Rossi"); 
 
johnSmith.greets = function() { 
  console.log("Hello " + this.name + " " + this.surname + "!"); 
}; 

This code will create a new method greets() for the johnSmith object without affecting the structure of marioRossi.

Basically, while creating objects, we can start from a common structure defined by a constructor and then customize it to our needs.

But how do we change the structure of all objects created using a constructor? For example, suppose that after creating several object using the Person() constructor, we want all the Person instances to have the greets() method. We can do it by exploiting one of the most interesting features of Object-Oriented Programming in JavaScript—the prototype.

In our case, we will proceed in the following way:

Person.prototype.greets = function() { 
  console.log("Hello " + this.name + " " + this.surname + "!"); 
}; 

This assignment means that all objects created using the Person() constructor will instantly have available also the greets() method.

To be precise, the new method is not directly attached to each object, but it is accessible as if it were its method. This is possible, thanks to the prototyping mechanism that represents the basis of inheritance in Object-Oriented Programming in JavaScript, as we will discuss later in the book.

In JavaScript, the prototype of an object is a kind of reference to another object. The objects we create through the literal notation implicitly refer to Object as their prototype.

When we create an object using a constructor, its prototype object is the prototype of the constructor.

If we try to access a property or method of an object that the object itself has not, JavaScript looks for it among the properties and methods of its prototype. So, in our previous example, if we try to access the greets() method of the marioRossi object, JavaScript does not find it among its methods, but it will find it among the methods of its prototype.

The prototype of an object can in turn have another prototype. In this case, the search for a property or method goes up the prototype chain until you get object-the basic prototype of all objects.

JavaScript built-in objects have a prototype reference too. In most cases, their management is quite similar to the prototypes management of objects created through our constructors. This allows us to extend functionality not provided by the built-in objects in a rather simple and elegant way.

For example, if we want to make a padding method available to all strings, we can work on the prototype of the String() constructor, as shown here:

String.prototype.padLeft = function(width, char) { 
  var result = this; 
  char = char || " "; 
 
  if (this.length < width)  { 
    result = new Array(width - this.length + 1).join(char) + this; 
  } 
  return result; 
}; 

With this definition we can use padLeft() as if it were a built-in method of all strings, as shown in the following example:

console.log("abc".padLeft(10, "x"));      //"xxxxxxxabc" 

Using classes

So far, we created objects using two mechanisms: the literal notation and the constructor. These mechanisms let us create objects with a simple approach, without too many formalities.

However, most developers are used to creating objects from the class construct. In fact, many Object-Oriented languages let the developer define classes and create objects as an instance of those classes.

The ECMAScript 2015 (also known as ECMAScript 6 or ES6) specifications introduce the class construct in JavaScript too. However, this construct has nothing to do with the classes of the traditional Object-Oriented Programming paradigm.

While in other languages, such as Java or C#, a class is an abstract description of the structure of an object, in JavaScript the class construct is just a syntactic simplification of the approaches to create objects we have already seen. The JavaScript class construct provides a much simpler and clearer syntax for managing constructors, prototypes, and inheritance.

The new class construct creates order among the different ways of object creation and aims to apply the best practice in prototype management.

Let's take a look at what a class looks like:

class Person { 
  constructor(name, surname) { 
    this.name = name; 
    this.surname = surname; 
  } 
} 

This class defines a constructor for objects of type Person. It is fully equivalent to the following old-style JavaScript code:

function Person(name, surname) { 
  "use strict"; 
  this.name = name; 
  this.surname = surname; 
} 

We can realize that classes are just syntactic sugar for the constructor's definition, simply getting the type of a class by means of the typeof statement:

console.log(typeof Person);   //function 

We can create an object using a class just as we do with constructors, as shown by the following example:

var person = new Person("John", "Smith"); 

However, unlike a constructor, we cannot invoke a class like a function, since the following code will raise an exception:

var person = Person("John", "Smith"); 

This ensures that we do not run the risk of the side effects that affect traditional constructors.

We can assign a class definition to a variable and then use the variable as an object constructor, as in the following example:

var Person = class { 
  constructor(name, surname) { 
    this.name = name; 
    this.surname = surname; 
  } 
}; 
 
var person = new Person("John", "Smith"); 

From a syntactic point of view, a class is a collection of methods included in braces and identified by a name.

One of these methods is the constructor() method, whose task is to define and initialize the properties:

class myClass { 
  constructor(value1, value2) { 
    this.property1 = value1; 
    this.property2 = value2; 
    this.property3 = ""; 
  } 
 
  method1() { 
    ... 
  } 
 
  method2() { 
    ... 
  } 
} 

The constructor of a class is a method with the reserved name constructor. You cannot have more than one constructor() method in a class.

The constructor method returns, by default, the new instance if it has no return statement, as a common JavaScript constructor. However, it is possible to override the default behavior by inserting a return statement in the constructor body. For example, the following code defines a constructor that returns a literal instance:

class myClass { 
  constructor(value) { 
    return { property1: value, property2: "" }; 
  } 
} 
 
var x = new myClass("foo"); 

All the methods defined in a class are attached to the prototype property of the class. The prototype property of a class is the prototype that the objects created using this class will have.

The choice to attach methods to the prototype of the class is the result of the application of a common best practice. Since usually methods are not dynamically changed, by attaching them to the prototype, this helps us to optimize memory management. In fact, if methods are not attached to the prototype, then they should be replicated on each newly created object with a proportional need of memory. Attaching methods to the prototype ensures that we have just one copy of them for all objects created from that class.

Unlike functions, classes are not hoisted. This means that while a function can be used before its declaration, a class cannot.

So, the following code will raise an exception:

var person = new Person(); 
 
class Person {...} 

The features of classes described so far are the basic ones. We will come back to explore other features of new class construct later in the book.

Summary

In this introductory chapter, we recalled some concepts related to object management in JavaScript.

We explored two approaches in creating objects: the literal-based approach and the constructor-based one. The first one is very simple but not practical when we need more generalization, while the second approach is a bit more complex but effective.

We also introduced the new class construct and analyzed how it simplifies the definition of object constructors and the use of prototypes.

In the next chapter, we will analyze how JavaScript applies the Object-Oriented Programming principles.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Covering all the new Object-Oriented features introduced in ES6, this book shows you how to build large-scale web apps
  • Build apps that promote scalability, maintainability, and reusability
  • Learn popular Object-Oriented programming (OOP) principles and design patterns to build robust apps
  • Implement Object-Oriented concepts in a wide range of front-end architectures

Description

ECMAScript 6 introduces several new Object-Oriented features that drastically change the way developers structure their projects. Web developers now have some advanced OOP functionality at their disposal to build large-scale applications in JavaScript. With this book, we'll provide you with a comprehensive overview of OOP principles in JavaScript and how they can be implemented to build sophisticated web applications. Kicking off with a subtle refresher on objects, we'll show you how easy it is to define objects with the new ES6 classes. From there, we'll fly you through some essential OOP principles, forming a base for you to get hands-on with encapsulation. You'll get to work with the different methods of inheritance and we'll show you how to avoid using inheritance with Duck Typing. From there, we'll move on to some advanced patterns for object creation and you'll get a strong idea of how to use interesting patterns to present data to users and to bind data. We'll use the famous promises to work with asynchronous processes and will give you some tips on how to organize your code effectively. You'll find out how to create robust code using SOLID principles and finally, we'll show you how to clearly define the goals of your application architecture to get better, smarter, and more effective coding. This book is your one-way ticket to becoming a JavaScript Jedi who can be counted on to deliver flexible and maintainable code.

Who is this book for?

This book is ideal for you if you are a JavaScript developers who wants to gain expertise in OOP with JavaScript to improve your web development skills and build professional quality web applications.

What you will learn

  • Master JavaScript s OOP features, including the one s provided by ES6 specification
  • Identify and apply the most common design patterns such as Singleton, Factory, Observer, Model-View-Controller, and Mediator Patterns
  • Understand the SOLID principles and their benefits
  • Use the acquired OOP knowledge to build robust and maintainable code
  • Design applications using a modular architecture based on SOLID principles

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 29, 2016
Length: 292 pages
Edition : 1st
Language : English
ISBN-13 : 9781785889103
Category :
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jun 29, 2016
Length: 292 pages
Edition : 1st
Language : English
ISBN-13 : 9781785889103
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
R$50 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
R$500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts
R$800 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just R$25 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total R$ 791.97
Mastering JavaScript Design Patterns
R$245.99
Mastering JavaScript Object-Oriented Programming
R$272.99
Modular Programming with JavaScript
R$272.99
Total R$ 791.97 Stars icon

Table of Contents

12 Chapters
1. A Refresher of Objects Chevron down icon Chevron up icon
2. Diving into OOP Principles Chevron down icon Chevron up icon
3. Working with Encapsulation and Information Hiding Chevron down icon Chevron up icon
4. Inheriting and Creating Mixins Chevron down icon Chevron up icon
5. Defining Contracts with Duck Typing Chevron down icon Chevron up icon
6. Advanced Object Creation Chevron down icon Chevron up icon
7. Presenting Data to the User Chevron down icon Chevron up icon
8. Data Binding Chevron down icon Chevron up icon
9. Asynchronous Programming and Promises Chevron down icon Chevron up icon
10. Organizing Code Chevron down icon Chevron up icon
11. SOLID Principles Chevron down icon Chevron up icon
12. Modern Application Architectures Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.7
(6 Ratings)
5 star 83.3%
4 star 0%
3 star 16.7%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Michael Sankovich Jan 27, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
A great read for getting into the OO sides of web dev
Amazon Verified review Amazon
Amazon Customer Jul 20, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book, I would definitely recommend it to anyone who wants to improve his or her OOP Javascript skills, and move to the next level of Javascript language skills. It cowers all the main subjects, beginning from OOP basics, prototypical inheritance, polymorphism inheritance and encapsulation JS implementation, and ending with Object Oriented Design principles, and design patterns. It will definitely provide you with solid foundation for your JS development and help you answer all hard JS OOP interview questions. It does not relay on any library and teaches how to write OOP Javascript code with no dependency on anything else but pure JS language. Reading this book was a great source of insights for me personally, Would definitely recommend!
Amazon Verified review Amazon
Sung H. Byun Jun 08, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I had some OO javascript experience before I picked up this book. But this book really opened my eyes wide. Very through but incrementally explaining OO in javascript.
Amazon Verified review Amazon
sapo Aug 11, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Really usefull and complete!
Amazon Verified review Amazon
Dario Chini Sep 13, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The book is truly complete. It is useful not only for those not familiar with Object Oriented Design principles, but also for those who may want to go over the described methodologies in the future. It is strongly recommended for those who do not have a structured course on JavaScript, or those who need to improve OOP especially on considerable codebases.Theory and practice are well balanced with complete examples. The book reads easily.We bought more than 20 copies for developers for their professional growth and to unify their theoretical basis.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.