Preface....9
Who is this book for?....9
How to Get the most out of this book?....9
Download the example code files....9
Obtain the images you will need....10
Chapter 1 – Strings and Regular Expressions....11
Unicode....11
Characters and Code points....11
String methods you should know about....13
Regular Expressions....17
Literal Characters....18
Flags/modifiers in Regular Expressions....19
RegExp Class....22
Character Classes together with brackets in Regular Expressions....22
Regular Expression character classes....23
Unicode: flag "u" and class \p{...}....24
Quantifiers in Regular Expressions....24
Alternatives....27
Grouping....27
Nested Groups....28
Named groups....30
Methods of the RegExp Class....31
String Methods on Regular Expressions....31
Search Method – search ()....31
Replace Method – replace ()....32
Summary....35
Chapter 2 - Asynchronous Programming....36
Callbacks....37
Timers....39
Canceling setTimeout using clearTimeout function....42
setInterval function....42
JavaScript Events....43
Network Events: XMLHttpRequest, Callbacks....43
Create XMLHttpRequest....44
Callback Hell....50
Promises....53
Immediately Settled Promises....55
Consuming Promises....56
Promise Chaining....57
Error – Rejection Handling....58
Try and Catch statement....59
Promise all....61
Promise Race....63
Promise Any....63
Async function....65
The syntax for the await is:....65
Arrow functions:....66
Anonymous and named functions:....66
Object methods:....66
Methods:....66
Promise-based Fetch API....66
Async/await Error Handling....78
for-await-of....79
Recall and async generators....81
Exercise....82
Summary....83
Chapter 3: JavaScript Modules....84
What are modules?....85
Exports and Imports....85
Exporting features without a name....89
Default keyword as reference....89
Re-exporting....90
Dynamic Imports....91
Important to know!....93
Summary....93
Chapter 4: Basic to Intermediate JavaScript....94
How to Run JavaScript?....95
How to write comments in JavaScript?....98
Identifiers....98
Statements....99
Case Sensitivity....99
Primitive and Object types....99
Variables and Assignment....99
Declaring a variable....100
Initializing a variable....100
Var, Let, and Const....101
Let....102
Const....102
Number Literals....103
String Literals....103
Template Literals....103
Arithmetic Operators....105
String Concatenation +....107
Boolean Values....107
Null and Undefined....107
Comparison and Logical Operators....107
Objects....108
Create Objects using new keyword....109
Creating objects using Object.create()....110
Primitives passed by value....111
Arrays....112
Array Literals....112
Create Arrays using new Array ()....113
Spread Operator....113
Access Array Elements....114
Conditional Statements or Branches....115
If-else statement....115
Else if statement....116
Conditional (ternary) operator....116
Switch Statement....116
Assignment Operator....118
Operator....119
While Loop....119
Do While Loop....119
For Loop....120
for/of loop with objects....120
Object.keys() – for/of....121
Object.entries() – for/of....121
for/in loop....122
Functions....122
Declaring Functions....123
Invoke Functions....124
Function Expression....124
Invoke Function Expression....125
Arrow Function....125
Arrow function on arrays....126
Passing Arguments to functions....127
Default function parameters....128
Closures....128
OOP – Classes....130
Classes....131
Inheritance....131
Setters and Getters....133
Static properties and methods....133
Overriding methods....134
Strict Mode....135
‘This’ keyword–function context....137
‘This’ keyword – method invocation....138
Summary....138
Chapter 5: Final Chapter....139
DOM – Document Object Model....139
Introduction....139
DOM vs HTML Markup....146
DOM Tree and Nodes....148
Malformed HTML and DOM....155
Access the DOM Elements....156
Getting Element By ID....159
Getting Elements by Class name....161
Getting Elements by Tag name....163
Query Selectors....164
Traversing the DOM....167
Root Nodes....168
Parent Nodes....170
Children Nodes....172
Sibling Properties....177
Directions of Traversing....180
Select a specific child....183
Traversing DOM Upwards....184
Traversing the DOM Sideways....185
Creating, Inserting, and Removing Nodes from DOM....186
Creating New DOM Nodes....186
Insert Created Nodes Into the DOM....188
Modify DOM Classes, Styles, and Attributes....189
Modify the CSS styles....192
Modify the Attributes....194
JavaScript Events....198
Event Handler & Event Listener....198
Inline Event Handlers....198
Event Handler Properties....200
Event Listeners....201
Most Common JavaScript Events....202
Keyboard Events....202
Form Events....202
Summary....203
About the author....204
Appendix A: Basic to Intermediate JavaScript book....205
Appendix B: Exercises and learn more about JavaScript, HTML, and PHP....207
Appendix C: Resources....207
Learn the real power of Modern JavaScript and learn the hard parts with ease.
With the help of this book, you will become a real JavaScript programmer! In this book, we will embrace functional, object-oriented, and asynchronous programming. We will learn how to handle errors like a pro.
JavaScript from Zero to Hero is a complete guide that will teach you the basics of JavaScript and the most advanced features starting from the JavaScript E6 version onwards.This book is organized into chapters for quick access and easy understanding. If you are new to programming, then the last two chapters are for you! These two chapters will get you the basics before starting to learn the advanced features. The book combines theory, sample code, and screenshots that will help you take advantage of all that’s new. These books cover basic to advanced features like variables, values, types, objects, functions, classes, arrays, modules, promises, asynchronous programming, async/await, MAPS, SET, JSON DOM, operators, regular expressions, and much more.
I know that your time is precious, so I don’t want to waste it with old and outdated concepts. Only the new concepts are the ones that you need and that are essential for you to find a job.
The JavaScript programming language is one of the top 3 web development languages. The IT industry covers 2.3 trillion US dollars in the USA, so if you want to access this industry, then JavaScript is the language you must know.
Yes, the JavaScript developers are the ones that are amongst the highest paid in the world, so being proficient in JavaScript will help you never run out of job options.
Yes, the last two chapters will help you learn the foundations of JavaScript, so the core features will be explained there.
This book is for:
JavaScript is a language that can be mastered easily only if you have a good guide that details each topic. This book will ensure that you learn the most up-to-date features demanded by the current hot job market. JavaScript can be complex if you don’t have the right step-by-step guide with practical examples.