Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
21 views

Learnjavascriptfrombeginnertomaster Sample

This book is a guide to learning JavaScript from beginner to master level. It is published through Leanpub, which allows for iterative publishing and reader feedback. The book contains 10 chapters that cover JavaScript fundamentals like variables, operators, control flow and more advanced topics such as objects, functions and intermediate concepts. Each chapter also includes a quiz to test the reader's understanding.

Uploaded by

cemerlang satu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Learnjavascriptfrombeginnertomaster Sample

This book is a guide to learning JavaScript from beginner to master level. It is published through Leanpub, which allows for iterative publishing and reader feedback. The book contains 10 chapters that cover JavaScript fundamentals like variables, operators, control flow and more advanced topics such as objects, functions and intermediate concepts. Each chapter also includes a quiz to test the reader's understanding.

Uploaded by

cemerlang satu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Learn JavaScript: From Beginner to Master

VigoWebs
This book is for sale at http://leanpub.com/learnjavascriptfrombeginnertomaster

This version was published on 2020-03-08

This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing
process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and
many iterations to get reader feedback, pivot until you have the right book and build traction once
you do.

© 2019 - 2020 VigoWebs


Contents

Chapter 1 - Introduction to JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


What Is JavaScript? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
How JavaScript was created . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
JavaScript and the ECMAScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
JavaScript as Interpreted Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
How to run the JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Script Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Chapter 1 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Chapter 2 - Variables and Datatypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3


What is Variable? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 2 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Chapter 3 - Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Operators in JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Chapter 3 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Chapter 4 - Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9


Control Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Block Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Conditional statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Chapter 4 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Chapter 5 - Loops and Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11


Loops and Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Chapter 5 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Chapter 6 - Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Chapter 6 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Chapter 7 - Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
CONTENTS

Array methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Multi-dimensional Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Chapter 7 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Chapter 8 - Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Creating Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Chapter 8 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Chapter 9 - Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Defining Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Property descriptors and flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Seal an Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Property getters and setters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Chapter 9 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Chapter 10 - Intermediate JavaScript 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24


Strict mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Truthy and Falsy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Type conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Converting strings to numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Automatic Semicolon Insertion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Avoid floating point problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Chapter 10 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

Chapter 11 - Intermediate JavaScript 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26


Boxed objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Hoisting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Chapter 11 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Chapter 12 - Intermediate JavaScript 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28


Pass by value or Pass by reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Call stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
What is this? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
call, apply and bind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Chapter 12 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Chapter 13 - Prototypes and Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30


Prototypes and Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
CONTENTS

Prototypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Chapter 13 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

Chapter 14 - Object Oriented JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32


Object Oriented JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Chapter 14 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Chapter 15 - ES6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
ES6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Transpile and Polyfill . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Block Scope Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Spread and Rest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Default parameter value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Destructuring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Object Literal Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Template Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Chapter 15 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

Chapter 16 - ES6 Part 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41


ES6 Continues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Arrow functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
for..of loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Generators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Chapter 16 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Chapter 17 - Class and Promises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43


Class and Promises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Promises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Chapter 17 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

Chapter 18 - Advance JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45


Advance JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Event Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Async functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Tail call optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Proxies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Reflect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Chapter 18 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
CONTENTS

Chapter 19 - Working with DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47


Working with DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Document Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
How to access DOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Find an Element by ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Find an Element by Tag name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Find an Element by class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Find elements by CSS selectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Working with attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Changing CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Working with Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Window onload and onunload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Adding new elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Removing HTML elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Chapter 19 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

Chapter 20 - Event Listener and BOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50


Event Listener and BOM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
addEventListener . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Event bubbling and Event Capturing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Turing off propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
BOM or Browser Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Chapter 20 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Chapter 21 - HTML5 APIs and Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52


HTML5 APIs and Ajax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Geoloaction API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Web Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Localstorage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Offline Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Web workers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
XMLHttpRequest or XHR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Chapter 21 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

Chapter 22 - JavaScript Oddities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54


JavaScript Oddities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Equal comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
[ ] == ![ ] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
NaN is not equal to NaN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
baNaNa . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Minimal value is greater than zero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Adding arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Trailing commas in array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
undefined and Number . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
CONTENTS

null is an object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Precision of 0.1 + 0.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Comparison of three numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Object as a key of object’s property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
try..catch finally . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Multiple inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
A class of class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Tricky arrow functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Arrow functions cannot be a constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
arguments in arrow functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Tricky return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Math.max() less than Math.min() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Comparing null to 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Default behavior Array.prototype.sort() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Array and Object addition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Chapter 22 - Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Chapter 1 - Introduction to JavaScript
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

What Is JavaScript?
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

How JavaScript was created


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

JavaScript and the ECMAScript


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

JavaScript as Interpreted Language


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

How to run the JavaScript


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Inline JavaScript
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 1 - Introduction to JavaScript 2

External JavaScript
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Script Loading
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 1 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 2 - Variables and Datatypes
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

What is Variable?
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Data Types
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Number
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

String
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Boolean
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Null
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 2 - Variables and Datatypes 4

Undefined
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Objects
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 2 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 3 - Operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Operators in JavaScript
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Assignment operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Comparison operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Arithmetic operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Bitwise operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Bitwise AND: &

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 3 - Operators 6

Bitwise OR: |

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Bitwise X OR: ^

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Bitwise NOT: ∼

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Left shift: <<

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Right shift: >>

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Zero-fill right shift: >>>

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Logical operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Logical AND: &&

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Logical OR: ||

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 3 - Operators 7

Logical NOT: !

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

String operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Conditional or ternary operator


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Comma operator
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Unary operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

typeof

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

delete

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

void

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 3 - Operators 8

Relational operators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

in

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Grouping operator
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 3 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 4 - Control Flow
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Control Flow
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Block Statements
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Conditional statements
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

if-else statement
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

switch statement
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Exception Handling
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 4 - Control Flow 10

try … catch
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

finally block
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 4 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 5 - Loops and Iteration
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Loops and Iteration


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

for loop
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

while statement
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

do … while Statement
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

break statement
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

continue statement
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 5 - Loops and Iteration 12

for..in statement
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

for..of statement
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 5 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 6 - Functions
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Functions
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Function declarations
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Function expressions
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

immediately invoked function


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Parameters and arguments


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

arguments object
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 6 - Functions 14

Chapter 6 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 7 - Arrays
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Arrays
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Creating an array
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Populating array
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Looping over an Array


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Array methods
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

concat
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 7 - Arrays 16

join
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

push
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

pop
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

shift
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

unshift
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

slice
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

splice
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

reverse
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 7 - Arrays 17

sort
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

indexOf
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

lastIndexOf
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

forEach
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

map
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

filter
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

every
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

some
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 7 - Arrays 18

reduce
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Multi-dimensional Arrays
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 7 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 8 - Objects
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Objects
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Overview
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Creating Objects
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object initializers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Constructor function
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 8 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 8 - Objects 20

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 9 - Objects
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Objects
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Defining Methods
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Iteration
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

for…in loop
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.keys()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.getOwnPropertyNames()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 9 - Objects 22

Property descriptors and flags


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Non-writable
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Non-enumerable
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Non-configurable
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.defineProperties
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Seal an Object
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.preventExtensions(obj)
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.seal(obj)
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 9 - Objects 23

Object.freeze(obj)
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.isExtensible(obj)
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.isSealed(obj)
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.isFrozen(obj)
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Property getters and setters


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 9 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 10 - Intermediate JavaScript 1
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Strict mode
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Changes in strict mode


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Truthy and Falsy


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Type conversion
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Converting strings to numbers


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

parseInt()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 10 - Intermediate JavaScript 1 25

parseFloat()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Number()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Automatic Semicolon Insertion


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Avoid floating point problems


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 10 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 11 - Intermediate JavaScript 2
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Boxed objects
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Hoisting
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Scope
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Lexical scope
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Closures
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Closures inside loop


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 11 - Intermediate JavaScript 2 27

Chapter 11 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 12 - Intermediate JavaScript 3
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Pass by value or Pass by reference


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Call stack
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

What is this?
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Default binding
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Implicit binding
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

call, apply and bind


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 12 - Intermediate JavaScript 3 29

Using call and apply


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 12 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 13 - Prototypes and
Inheritance
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Prototypes and Inheritance


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Prototypes
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Constructors
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object.create()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Performance
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 13 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 13 - Prototypes and Inheritance 31

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 14 - Object Oriented
JavaScript
Object Oriented JavaScript
Object oriented programming or OOP is a methodology to create our program using Objects and
Classes. The basic idea of OOP is that we use objects to model real world things that we want
to represent inside our programs, and provide a simple way to access functionality that would
otherwise be hard or impossible.
Objects can contain property, which represents information about the thing we are trying to model
and methods or actions that represents a behavior. For example, if we think a car as an object,
then the number of wheels, the type of car, the color of car becomes the properties of the car. And
starting or stopping the car becomes actions. Data in objects can be stored neatly without exposing
to the outer world (which is called encapsulation), can be given a specific name to refer to (which is
sometimes called a namespace).
Consider we are going to develop an application for an organization where there are developers
and managers. To handle the data of developers and managers we could create an object model like
below:

1 function Developer(name, id) {


2 this.name = name;
3 this.id = id;
4 this.role = 'Developer';
5 this.greeting = function() {
6 console.log('Hello, I am a Developer');
7 }
8 }
9 function Manager(name, id) {
10 this.name = name;
11 this.id = id;
12 this.role = 'Manager';
13 this.greeting = function() {
14 console.log('Hello, I am a Manager');
15 }
16 }
Chapter 14 - Object Oriented JavaScript 33

If you can observe the above code, it has duplicate properties in both model, name and id. We
can make this better by creating one parent objects and create two sub-objects for developer and
manager.

1 function Employee(name, id) {


2 this.name = name;
3 this.id = id;
4 }
5 function Developer(name, id) {
6 Employee.call(this, name, id);
7 this.role = 'Developer';
8 this.greeting = function() {
9 console.log('Hello, I am a Developer');
10 }
11 }
12 function Manager(name, id) {
13 Employee.call(this, name, id);
14 this.role = 'Manager';
15 this.greeting = function() {
16 console.log('Hello, I am a Manager');
17 }
18 }

We have moved the common properties to the top of the prototype chain and let the child objects
to call them. This make our developer and manager constructors more manageable. If you inspect
more, we can see that the greeting action has almost similar in both. It is same in both except for
the role. So we can also move this method to the top.

1 function Employee(name, id) {


2 this.name = name;
3 this.id = id;
4 }
5 Employee.prototype.greeting = function() {
6 console.log('Hello, I am a ' + this.role);
7 }
8 function Developer(name, id) {
9 Employee.call(this, name, id);
10 this.role = 'Developer';
11 }
12 Developer.prototype = Object.create(Employee.prototype);
13 Developer.constructor = Developer;
14 function Manager(name, id) {
15 Employee.call(this, name, id);
Chapter 14 - Object Oriented JavaScript 34

16 this.role = 'Manager';
17 }
18 Manager.prototype = Object.create(Employee.prototype);
19 Manager.constructor = Manager;

This looks even better. We have, like moved the common properties to top, moved the common
methods to the top. We have also make our Developer and Manager inherits data and behavior from
the Employee, so we can reuse functionality common to all the object types rather than having to
duplicate it. Now let us check our models by creating instances of them.

1 var christine = new Manager('Christine', 1);


2 var joseph = new Developer('Joseph', 2);
3 christine.greeting();
4 // Hello, I am a Manager
5 joseph.greeting();
6 // Hello, I am a Developer

The greeting method is same in both objects and implemented the same functionality. But their
result are different based on child objects. The ability of multiple object types to implement the
same functionality is called polymorphism.
If you have noticed, we have assigned the constructor property of Developer (or Manager) to the
same function again after the prototype. This is because, when we are overwriting the prototype,
it also overwrites the constructor property to Employee. So we have manually adjust it back to its
original value.
One of the other features in OOP is Encapsulation. Encapsulation is the ability of an object to be a
container (or capsule) for its member properties, including variables and methods. This object can
protect its data from outside world or restricting its access. Imaging our Developer object needs
to have a private data which is noOfWorkingDays. It should be accessed like name or id which are
common. Let us see how can we achieve this.
If you can remember, functions create scope. That means variables declared inside a function can
not be accessed from outside. So creating a local variable, we can encapsulate our data inside the
function.

1 function Developer(name, id) {


2 Employee.call(this, name, id);
3 this.role = 'Developer';
4 var numOfWorkingDays = 0;
5 }
6 var joseph = new Developer('Joseph', 2);
7 joseph.noOfWorkingDays; // undefined
Chapter 14 - Object Oriented JavaScript 35

If we want to expose this data to outside, we can create methods to write and read the data from
the object. This way we can be sure that there is no way to directly manipulate our private data
noOfWorkingDays. Any read or write operation should be done from our generated methods.

1 function Developer(name, id) {


2 Employee.call(this, name, id);
3 this.role = 'Developer';
4
5 var numOfWorkingDays = 0;
6
7 this.updateWorkingDays = function() {
8 numOfWorkingDays++;
9 }
10
11 this.getWorkingDays = function() {
12 return numOfWorkingDays;
13 }

We have created a method updateWorkingDays to increment the working days by 1 whenever


invoked and getWorkingDays to access the value of the private variable numOfWorkingDays. Note
that these methods are specific to Developer. Manager does not have these methods.

1 var joseph = new Developer('Joseph', 2);


2 joseph.getWorkingDays(); // 0
3 joseph.updateWorkingDays();
4 joseph.getWorkingDays(); // 1

These private variables private to these objects which means other instance of the Developer object
will have its own numOfWorkingDays.

1 joseph.getWorkingDays(); // 1
2 var andrew = new Developer('Andrew', 3);
3 andrew.getWorkingDays(); // 0
4 andrew.updateWorkingDays();
5 andrew.getWorkingDays(); // 1

Because of the way JavaScript works, with the prototype chain, etc., the sharing of functionality
between objects is often called delegation. Specialized objects delegate functionality to a generic
object type.
In terms of using inheritance in your own code, you probably won’t use it often, especially to begin
with, and in small projects. It is a waste of time to use objects and inheritance just for the sake of it
when you don’t need them. But as your code bases get larger, you are more likely to find a need for
Chapter 14 - Object Oriented JavaScript 36

it. If you find yourself starting to create a number of objects that have similar features, then creating
a generic object type to contain all the shared functionality and inheriting those features in more
specialized object types can be convenient and useful.
When using inheritance, you are advised to not have too many levels of inheritance, and to keep
careful track of where you define your methods and properties. It is possible to start writing code that
temporarily modifies the prototypes of built-in browser objects, but you should not do this unless
you have a really good reason. Too much inheritance can lead to endless confusion, and endless pain
when you try to debug such code.
Finally, using functions with prototype looks like lot of work to link objects. But since ES6
introduction of class, extends and super, it becomes very easy to create classes and share
functionalities among them. We will explain all the ES6 features in the coming lessons.

Chapter 14 - Quiz
Oops! That was an incredible achievement. OOP or Object oriented programming is an important
concept not only in JavaScript but in most of the languages that every developer should know. Go
ahead and take this simple questions before you continue your journey.
1. Object oriented programming or OOP is a methodology to create our program using which of
these?

a. Object and class


b. Data and behavior
c. Functions and scope

2. If you think of a car as an object, which of the below can be said to equal to starting the car?

a. method
b. property
c. data

3. Having a parent class to have common properties and methods leads to reducing code duplication.

a. True
b. False

4. The ability of multiple object types to implement the same functionality is called what?

a. Polymorphism
b. Encapsulation
Chapter 14 - Object Oriented JavaScript 37

c. OOP

5. The idea of OOP is to use objects to model real world things that we want to represent, and provide
a simple way to access functionality that would otherwise be hard or impossible.

a. True
b. False

6. A class sometimes can shield its member from outside world and restrict access to them. How is
this behavior called?

a. Polymorphism
b. Encapsulation
c. OOP

7. Find the missing piece of code to complete the inheritance?

1 function Employee(name, id) {


2 this.name = name;
3 this.id = id;
4 }
5
6 Employee.prototype.greeting = function() {
7 console.log('Hello, I am a ' + this.role);
8 }
9
10 function Developer(name, id) {
11 Employee.call(this, name, id);
12 this.role = 'Developer';
13 }
14
15 // .....
16 Developer.constructor = Developer;

a. Developer.prototype = Object.create(Employee.prototype);
b. Employee.prototype = Object.create(Employee.prototype);
c. Employee.prototype = Object.create(Developer.prototype);

8. How can we create encapsulation in JavaScript?

a. Using functions scope


Chapter 14 - Object Oriented JavaScript 38

b. Using prototype
c. Using inheritance

9. Does different instances of a class share the same private variables?

a. No
b. Yes

10. It is advised to have too many levels of inheritance. State true of false.

a. True
b. False

11. With the prototype chain, etc., the sharing of functionality between objects is called … ?

a. sharing
b. delegation
c. polymorphism

Answers
1. a); Object oriented programming or OOP is a methodology to create our program using which
of Object and class.
2. a); Starting or stopping car denotes an action. And in objects methods are doing some actions
and properties are having some data.
3. a); True. When a parent class have common properties and methods, it leads to reducing code
duplication.
4. a); The ability of multiple object types to implement the same functionality is called Polymor-
phism.
5. a); True. The basic idea of OOP is that we use objects to model real world things that we want
to represent inside our programs, and provide a simple way to access functionality that would
otherwise be hard or impossible.
6. b); Encapsulation is the ability of an object to be a container (or capsule) for its member
properties, including variables and methods. This object can protect its data from outside world
or restricting its access.
7. a); To inherit properties from Employee object, we need to modify the prototype of Developer
to Developer.prototype = Object.create(Employee.prototype).
8. a); Functions create scope, that means variables declared inside a function cannot be accessed
from outside. So creating a local variable, we can encapsulate our data inside the function.
9. a); The private variables private to these objects which means other instance of the Developer
object will have its own numOfWorkingDays.
10. b); When using inheritance, you are advised to not have too many levels of inheritance since
it can lead to endless confusion, and pain.
11. b); The sharing of functionality between objects is often called delegation. Specialized objects
delegate functionality to a generic object type.
Chapter 15 - ES6
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

ES6
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Transpile and Polyfill


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Block Scope Declarations


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Spread and Rest


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Default parameter value


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Destructuring
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 15 - ES6 40

Object Literal Extensions


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Template Literals
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Tagged template literal


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Symbols
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Symbols as Object Properties


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 15 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 16 - ES6 Part 2
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

ES6 Continues
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Arrow functions
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

for..of loop
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Collections
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Maps
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

WeakMaps
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 16 - ES6 Part 2 42

Set
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

WeakSet
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Generators
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Modules
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

import
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 16 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 17 - Class and Promises
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Class and Promises


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Class
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

extends and super


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

new.target
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Static properties
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Getters and Setters


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 17 - Class and Promises 44

Promises
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Promise.race
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Limitations
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 17 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 18 - Advance JavaScript
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Advance JavaScript
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Event Loop
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Async functions
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Tail call optimization


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Proxies
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Reflect
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 18 - Advance JavaScript 46

Reflect.apply
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Reflect.construct()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Reflect.get()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Reflect.has()
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 18 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 19 - Working with DOM
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Working with DOM


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Document Object Model


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

How to access DOM


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Find an Element by ID
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Find an Element by Tag name


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Find an Element by class


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 19 - Working with DOM 48

Find elements by CSS selectors


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Working with attributes


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Changing CSS
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Working with Events


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Window onload and onunload


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Adding new elements


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Removing HTML elements


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 19 - Working with DOM 49

Chapter 19 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 20 - Event Listener and BOM
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Event Listener and BOM


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

addEventListener
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Event bubbling and Event Capturing


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Turing off propagation


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

stopImmediatePropagation
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

preventDafault
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 20 - Event Listener and BOM 51

BOM or Browser Object Model


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Window Size
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Location
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

History
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Navigator
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Popups
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 20 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 21 - HTML5 APIs and Ajax
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

HTML5 APIs and Ajax


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Geoloaction API
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Web Storage
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Localstorage
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

SessionStorage
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Offline Web Applications


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 21 - HTML5 APIs and Ajax 53

Web workers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

XMLHttpRequest or XHR
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 21 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 22 - JavaScript Oddities
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

JavaScript Oddities
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Equal comparison
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

[ ] == ![ ]

This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

NaN is not equal to NaN


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

baNaNa
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Minimal value is greater than zero


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 22 - JavaScript Oddities 55

Adding arrays
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Trailing commas in array


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

undefined and Number


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

null is an object
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Precision of 0.1 + 0.2


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Comparison of three numbers


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Object as a key of object’s property


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 22 - JavaScript Oddities 56

try..catch finally
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Multiple inheritance
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

A class of class
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Tricky arrow functions


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Arrow functions cannot be a constructor


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

arguments in arrow functions


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Tricky return
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.
Chapter 22 - JavaScript Oddities 57

Math.max() less than Math.min()


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Comparing null to 0
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Default behavior Array.prototype.sort()


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Array and Object addition


This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Chapter 22 - Quiz
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

Answers
This content is not available in the sample book. The book can be purchased on Leanpub at http:
//leanpub.com/learnjavascriptfrombeginnertomaster.

You might also like