Book Image

Learning ECMAScript 6

By : Narayan Prusty
Book Image

Learning ECMAScript 6

By: Narayan Prusty

Overview of this book

<p>ECMAScript 6 is the new edition to the ECMAScript language, whose specifications are inherited by JavaScript. ES6 gives a vast makeover to JavaScript by adding new syntaxes and APIs to write complex applications and libraries that are easier to debug and maintain. By learning the latest version of ECMAScript, you'll have a greater understanding of JavaScript and more confidence and fluency when developing with it - follow this book and use and adopt ES6 features into your work, instead of the usual tired JavaScript hacks and tricks.</p> <p>The book begins by introducing ECMAScript 6's built-in objects and &nbsp;shows you how to create custom Iterators. &nbsp;It also provides you with guidance on Next, how to write asynchronous code in a synchronous style using ES6, so you can unlock greater control and sophistication in the way you develop with JavaScript.</p> <p>Beyond this, you will also learn&nbsp;how to use Reflect API to inspect and manipulate object properties. Next, it teaches how to create proxies, and use it to intercept and customize operations performed on objects.&nbsp;Finally, it explains old modular programming techniques such as IIFE, CommonJS, AMD, and UMD and also compares it with ECMAScript modules and demonstrates how modules can increase the performance of websites when used.</p>
Table of Contents (16 chapters)

Understanding the Object-oriented JavaScript


Before we proceed with the ES6 classes, let's refresh our knowledge on the JavaScript data types, constructors, and inheritance. While learning classes, we will be comparing the syntax of the constructors and prototype-based inheritance with the syntax of the classes. Therefore, it is important to have a good grip on these topics.

The JavaScript data types

The JavaScript variables hold (or store) data (or value). The type of data variables that they hold is called as the data type. In JavaScript, there are seven different data types: number, string, Boolean, null, undefined, symbol, and object.

When it comes to holding objects, variables hold the object reference (that is, the memory address) instead of the object itself.

All the other data types other than object are called as primitive data types.

Note

The arrays and functions are actually the JavaScript objects.

Creating objects

There are two ways of creating an object in JavaScript, that is...