Learn ECMAScript
Narayan Prusty, MEHUL MOHAN
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Learn ECMAScript
Narayan Prusty, MEHUL MOHAN
About This Book
Get up and running with all the new features of ECMAScript and explore new ways of coding with JavaScript.
Key Features
- Grasp the latest features of ECMAScript and the best way to use it in production code
- Learn newly added native APIs to JS Engine and perform tasks efficiently with a cleaner code base
- Understand the more complex sides of JavaScript such as the inheritance model, low-level memory management, multithreaded environments, and web workers
Book Description
Learn ECMAScript explores implementation of the latest ECMAScript features to add to your developer toolbox, helping you to progress to an advanced level. Learn to add 1 to a variable andsafely access shared memory data within multiple threads to avoid race conditions.
You'll start the book by building on your existing knowledge of JavaScript, covering performing arithmetic operations, using arrow functions and dealing with closures. Next, you will grasp the most commonly used ECMAScript skills such as reflection, proxies, and classes. Furthermore, you'll learn modularizing the JS code base, implementing JS on the web and how the modern HTML5 + JS APIs provide power to developers on the web. Finally, you will learn the deeper parts of the language, which include making JavaScript multithreaded with dedicated and shared web workers, memory management, shared memory, and atomics. It doesn't end here; this book is 100% compatible with ES.Next.
By the end of this book, you'll have fully mastered all the features of ECMAScript!
What you will learn
- Implement methods associated with objects as per the latest ECMAScript specification
- Make use of the latest features of ECMAScript
- Make use of many new APIs in HTML5 and modern JavaScript implementation
- Use SharedArrayBuffers for superfast concurrent and parallel programming
- Perform asynchronous programming with JavaScript
- Implement the best ways and practices to perform modular programming in JavaScript
Who this book is for
This book is for web developers who have some basic programming knowledge and want to learn to write cleaner code with the power of ECMAScript.
Frequently asked questions
Information
Knowing Your Library
- The new properties and methods of the Number, Object, Math, and Array objects
- Representing numeric constants as binary or octal
- Creating multiline strings and the new methods of the String object
- Maps and sets
- Using array buffers and typed arrays
- How to iterate properly over arrays using some built-in methods
- String padding, and more!
Working with numbers
The binary notation
Here is an example:
let a = 0b00001111;
let b = 15;
console.log(a === b);
console.log(a);
true
15
The octal notation
const a = 017;
const b = 15;
console.log(a === b);
console.log(a);
true
15
Here is an example to demonstrate this:
const a = 0017;
const b = 15;
console.log(a === b);
console.log(a);
true
15
The Number.isInteger(number) method
Here is an example:
let a = 17.0;
let b = 1.2;
console.log(Number.isInteger(a));
console.log(Number.isInteger(b));
true
false
The Number.isNaN(value) method
let a = "NaN";
let b = NaN;
let c = "hello";
let d = 12;
console.log(Number.isNaN(a)); // false
console.log(Number.isNaN(b)); // true
console.log(Number.isNaN(c)); // false
console.log(Number.isNaN(d)); // false
You might ask, why not use == or the === operator instead of the Number.isNaN(value) method? The NaN value is the only value that is not equal to itself, that is, the expression NaN==NaN or NaN===NaN will return false.
isNaN versus Number.isNaN
isNaN(' '); // false => because Number(' ') is equal to 0 (a number)
isNaN(true); // false => because Number(true) is equal to 1 (a number)
The Number.isFinite(number) method
console.log(isFinite(10)); // true
console.log(isFinite(NaN)); // false
console.log(isFinite(null)); // true
console.log(isFinite([])); // true
console.log(Number.isFinite(10)); // true
console.log(Number.isFinite(NaN)); // false
console.log(Number.isFinite(null)); // false
console.log(Number.isFinite([])); // false