Home / IT Books / Mastering JavaScript

Mastering JavaScript

OOP was an important idea and a definite step forward from the traditional structured programming. However, many feel that OOP is overdone. Most OOP systems define complex and unnecessary class and type hierarchies. Another big drawback was that in the pursuit of hiding the state, OOP considered the object state almost immaterial. Though hugely popular, OOP was clearly flawed in many areas. Still, OOP did have some very good ideas, especially hiding the complexity and exposing only the interface to the outside world. JavaScript picked up a few good ideas and built its object model around them.

Chapter 1: JavaScript Primer 1
A little bit of history 2
How to use this book 3
Hello World 6
An overview of JavaScript 6
Comments 6
Variables 7
Constants 7
Number 8
String 11
Undefined values 13
Booleans 13
The instanceof operator 15
Date objects 15
The + operator 16
The ++ and — operators 17
Boolean operators 18
Equality 25
JavaScript types 27
Automatic semicolon insertion 30
JavaScript style guide 32
Whitespaces 32
Parentheses, line breaks, and braces 32
Quotes 34
End of lines and empty lines 34
Type checking 35
Type casting 35
Conditional evaluation 36
Naming 38
The eval() method is evil 39
The strict mode 39
Running JSHint 41
Chapter 2: Functions, Closures, and Modules 45
A function literal 46
A function declaration 46
Functions as data 49
Scoping 50
Global scope 51
Local scope 52
Function-level scope versus block-level scope 52
Inline function expressions 56
Block scopes 56
Function declarations versus function expressions 58
The arguments parameter 60
The this parameter 61
Invocation as a function 61
Invocation as a method 61
Invocation as a constructor 63
Invocation using apply() and call() methods 63
Anonymous functions 64
Anonymous functions while creating an object 64
Anonymous functions while creating a list 64
Anonymous functions as a parameter to another function 65
Anonymous functions in conditional logic 65
Closures 66
Timers and callbacks 69
Private variables 69
Loops and closures 70
Modules 71
Stylistic considerations 72
Chapter 3: Data Structures and Manipulation 75
Regular expressions 76
Exact match 77
Match from a class of characters 77
Repeated occurrences 81
Alternatives – OR 84
Beginning and end 84
Backreferences 84
Greedy and lazy quantifiers 85
Arrays 86
Maps 95
Sets 95
A matter of style 97
Chapter 4: Object-Oriented JavaScript 99
Understanding objects 99
Behavior of JavaScript objects 101
Prototypes 103
Instance properties versus prototype properties 104
Inheritance 110
Getters and setters 117
Chapter 5: JavaScript Patterns 121
Design patterns 122
The namespace pattern 123
The module pattern 124
ES6 modules 131
The factory pattern 131
The mixin pattern 133
The decorator pattern 134
The observer pattern 137
JavaScript Model-View-* patterns 139
Model-View-Controller 139
Models 140
Views 140
Controllers 141
The Model-View-Presenter pattern 141
Model-View-ViewModel 142
Chapter 6: Testing and Debugging 145
Unit testing 146
Test-driven development 147
Behavior-driven development 147
JavaScript debugging 154
Syntax errors 154
Using strict 155
Runtime exceptions 155
Console.log and asserts 156
Chrome DevTools 157
Chapter 7: ECMAScript 6 163
Shims or polyfills 164
Transpilers 164
ES6 syntax changes 165
Block scoping 165
Default parameters 167
Spread and rest 167
Destructuring 168
Object literals 170
Template literals 171
Maps and Sets 172
Symbols 175
Iterators 175
For..of loops 176
Arrow functions 176
Chapter 8: DOM Manipulation and Events 181
DOM 181
Accessing DOM elements 182
Accessing specific nodes 183
Chaining 191
Traversal and manipulation 191
Working with browser events 193
Propagation 194
jQuery event handling and propagation 195
Event delegation 198
The event object 199
Chapter 9: Server-Side JavaScript 201
An asynchronous evented-model in a browser 202
Callbacks 206
Timers 210
EventEmitters 211
Modules 212
Creating modules 213
npm 215
Installing packages 216
JavaScript performance 218
JavaScript profiling 218
The CPU profile 219
The Timeline view 220

Mastering JavaScript


Top books

About huydam

Check Also

[UWP] The program could not build Windows Universal Samples

If you get this error like this: “Type universe cannot resolve assembly: System.Runtime, Version=4.0.0.0, Culture=neutral, …

Leave a Reply

Your email address will not be published. Required fields are marked *