Chapter 0: Why this book?
- The history of this book (and the book series)
- You can’t make everyone happy
- This one goes out to the happy ones
- How is this book organized?
- The methodology: Bloom’s taxonomy
- 1. “Map of the JavaScript land”
- 2. Types of tutorials
- 3. Focusing on “knowledge transfer”, not “feature-listing”
- 4. Most of these books are either too theoretical or too practical
- What We’re Building
- Accompanying website
- List of major updates
Chapter 1: Starting slowly
- 1. Why programming?
- 2. Why JavaScript?
- 3. The JS ecosystem
- 4. How to get started
- 5. Playing by JS’ rules meaningfully
- 6. Can your calculator do that?
- 7. Recap
- Conclusion
Chapter 2: Evaluation, data types, operators, variables, and conditionals
- Evaluation in JavaScript
- Operators in JavaScript
- Introduction to variables
- Variables, assignment, and typeof
- Revisiting data types: strings vs numbers
- Making JavaScript respond in plain English
- Build your first simple game in JavaScript
- A gentle introduction to the object data type in JavaScript
- Understanding key-value pairs
- Re-writing your first simple game using objects (and comments!)
- If statements and blocks of code
- Conditionally executing multiple lines of code
- The basics of data type conversion
Chapter 3: Functions, primitives, and objects in JavaScript
- A Function is A Machine
- Generalizing Functions in JavaScript
- Anonymous functions
- Revisiting the age-checker app
- Conclusions
- What’s next?
- A quick note about var, let and const
Chapter 4: The Quick Prototype App
- Concepts to understand before building the app
- Building the Quick Prototyper App
- Using Github to Share code
- Updating Our Web Page Dynamically
- Reinforcing Your Learning Using Devtools Snippets
- Start Building the Quick Prototyper snippet
- Checking for Equality and Running Code Conditionally
- Adding a Second Component to Quick Prototyper
- Passing Custom Arguments to Function Calls Based on User Input
- Using else if
- Working with the button classes in Quick Prototyper
- Prompting For Multiple Components At a Time
- Conclusion
Chapter 5: Understanding Events in JavaScript
- What are Events in JavaScript
- Inline Event Handlers Using HTML Attributes
- How JavaScript Deals with Events
- Stopping Event Propagation
- Add an Event Handler to the Page Dynamically
- The Event Object
- Review: How does browser handle events?
- Some more practice
Chapter 6: Improving the UX on Quick Prototyper
- Adding badges to the list of components
- Adding Buttons To our App
- Adding the Navbar to our QuickPrototyper
- List of Updates Made to QuickPrototyperV10
Chapter 7: Introducing jQuery
- Understanding the basics of jQuery
- Adding the
textToEditandpopUpEditordivs - Styling the
popUpEditor
Chapter 8: The Anatomy of functions in ES6
- Comparing ES5 and ES6 functions in JavaScript
- Function definitions with a single parameter
- Function definitions with no parameters
- Converting ES5 to ES6 functions (and vice-versa)
Chapter 9: Learning JavaScript basics by coding tiny apps
- What’s fiction writing have to do with coding?
- Version one of our Learning JavaScript Project
- Version two of our Learning JavaScript Project
- Why is this important?
- Learning JS basics by coding tiny apps: Let’s build a choices game
- Escaping the console and the prompt function
- Building the “JS Money” game
- Using a ternary expression in our game
- Add CSS classes using JavaScript
- Conclusion
Chapter 10: Data Types and Constructors
- Objects VS non-objects
- Finding the type of primitives using the
typeofoperator - The number type
- The null type
- The undefined type
- The boolean type
- The
biginttype - The symbol type
- Understanding primitive data types in JavaScript
- Primitive types cannot be mutated
- The object type
- Wrapper objects on primitives in JavaScript
- Type constructors in JavaScript: The good, the bad, and the ugly
- What does the “new” operator do?
- Some built-in objects don’t need a constructor - because they’re static objects
- Building objects with user-defined constructor functions
- Rule of thumb: use literals rather than object function constructors
- Typecasting with type constructors
- Forgetting the new keyword pollutes global scope!
- Comparing primitive values in JavaScript
- Comparing objects in JavaScript
- Primitives are passed by value
- Objects are passed by reference
- Truthy and falsy values and coercion in JavaScript
- Conclusion
Chapter 11: JavaScript and the Browser
- “The states of matter” of a web page
- A sneak preview:
document.write - What is the DOM?
- Is the DOM a part of JavaScript?
- Where does JavaScript live?
- Browser and Web APIs
- JavaScript Engines and Browser Engines
- How a JavaScript Engine Works
- The Memory Heap
- The Call Stack
- Stack Overflow
- Recursion in JavaScript
- The memory heap and JavaScript variables
- Variable hoisting VS function hoisting
- Using the debugger to understand hoisting
- The global object
- The call stack, the global object, and the keyword “this”
- Functions, call stack, and execution contexts
- Why do we need the scope chain?
- Sibling functions don’t share a scope chain
- Back to the this keyword
- Conclusion
Chapter 12: JavaScript is Synchronous, Browser is Asynchronous
- JavaScript is Single-Threaded and Synchronous
- Synchronous JavaScript in an Asynchronous Browser
- Conclusion
Chapter 13: Basic JavaScript Caveats
- Higher-order functions
- Revisiting scope: global, function, and block scope
- Closures (the products of higher-order functions)
- Lexical Scope
- Variables: var VS let and const
- Operator precedence and associativity
- Default parameters in functions
- Using
call()andapply() - Implicit and explicit context of
this - Using
bind() - Working with local storage
- Method chaining
- JavaScript loading in an HTML page
- Nullish coalescing operator
- Optional chaining operator
Chapter 14: The Anatomy of a JavaScript Function: all the different ways of defining functions in JS
- 1. Function declarations
- 1a. Conditionals and function declarations
- 2. Function expressions
- 2a. Function expressions as IIFEs
- 2b. Function expressions as object methods
- 2c. Function expressions as shorthand methods in ES6 object literals
- 2d. Function expressions as shorthand methods with the computed properties syntax
- 2e. Function expressions as callbacks
- 2f. Function expressions as arrow functions
- 2f. How does the JavaScript engine load functions into the execution context?
- 3. Function constructors
- 4. Generator functions
- 5. Async / await functions
- Conclusion
Chapter 15: Understanding arguments and the spread operator
- How many arguments does a function expect?
- The
argumentsvariable - Can we use the arguments variable with arrow functions?
- How does the spread operator work in arrow functions?
- Understanding the
argumentslocal variable in depth
Chapter 16: JavaScript Arrays in Depth
- Using the
deletemethod on an array member - Does a value exist in an array?
- Use
Array.lengthto find the last member of array - Use Array.length to quickly trim an array
- Manipulating arrays with
pop - Manipulating arrays with
push - Manipulating arrays with
shift - Manipulating arrays with
unshift - Manipulating arrays with
Array.sliceandArray.splice - Destructuring Arrays
- Concat two arrays together
- Convert an array to a string
- Flipping the order of items in an array
- Sorting arrays with
Array.sort - Exercise: Sort a todo list
- Additional Exercise: Reverse the order of array
- Looping over arrays
- 2. Using the “optimized”
forloop - 3. Looping over a JS array with
for-of - 4. Don’t loop over a JS array with
for-in - 5. Looping over a JS array with the while loop
- 6. Looping over a JS array with the
do whileloop - Functional approach to looping over arrays in JS
- 7. Looping over arrays in JS with
forEach - 8. Looping over arrays in JS with
Array.prototype.filter - Using
Array.prototype.filterfollowed byArray.prototype.forEach - 10. Using
Array.prototype.map - 11. Using
Array.prototype.reduce - 12. Using
Array.prototype.some - 13.
Array.prototype.every - 14. Using
Array.prototype.find - 15. Using
Array.prototype.sort - Looping over arrays: Conclusion
Chapter 17: Sets and Maps in JavaScript
- A Set is a Collection of Unique Members
- Convert a set to an array
- Convert an array to a set
- Remove duplicates from an array using a set
- Just for fun (re-duplicate an array)
- Does a value exist in a set?
- Sets don’t consider objects the same even if they hold the same values
- Check the length of a set
- Using two sets to find the items that exist in both
- Deleting set members
- Comparing sets and weak sets
- Practical Uses of Weak Sets in JavaScript
- Looping over sets and weak sets
- Working with maps in JavaScript
- A map is like a “countable” object (i.e. a dictionary)
- Using the map data structure in JS
- Populating a map data structure in JS
- Retrieving all the key-value pairs from a map
- Passing more than one key-value pairs to a new map
- What is the size of a specific map?
- Adding key-value pairs to existing maps
- Does a key exist in a map?
- Returning a value from a map key in JS
- Deleting key-value pairs from maps in JS
- Clearing a map of all key-value pairs
- Convert a map to an array
- Convert a map to an object
- Comparing maps and objects
- Weak maps in JS
- Weak maps and weak sets help with memory use
- Looping over maps
- Looping over a map with a forEach
Chapter 18: JavaScript Objects in Depth
- What are objects in JS?
- Object literals and object accessors
- Nesting objects in other objects in JavaScript
- Working with object properties
- Running CRUD operations on object properties in JavaScript using brackets notation
- The difference between the dot notation and the brackets notation for object access
- Using ternary expressions to determine the value of a property
- Evaluating expressions inside objects using the brackets notation
- Listing out object properties
- JavaScript objects are “pass-by-reference”
- Passing objects to functions
- Accessing object properties from object methods
- Using
Object.createmethod - Built-in objects in JavaScript
- The String object
- The RegExp object
- Using RegExp in JavaScript
- Date object
- JSON (JavaScript Object Notation)
- Math object
- Working with property descriptors
- Working with the writable property descriptor
- Working with the enumerable property descriptor
- Working with the configurable property descriptor
- Working with getters and setters
- Destructuring objects in JavaScript
Chapter 19: Working with Objects, Arrays, and JSON
- Working With JSON Received From The Web
Chapter 20: Functional programming in JavaScript
- What is it?
- FP vs OOP
- Declarative and Imperative Paradigms
- Side Effects and Pure Functions
Chapter 21: Object-Oriented Programming in JavaScript
- What is OOP?
- Polymorphism
- Encapsulation
- Inheritance
- Classes
- Objects Store Both Functions And Data
- Building multiple objects
- Linking Objects with Object.create
- My name is Proto, Dunder Proto
- In JavaScript, functions are objects
- The Proper Way to Use
prototypeIs With A Constructor Function - Getting an Object’s Prototype
- Why JavaScript is not class-based “under the hood”
- Constructor functions and object-oriented JavaScript
- Arrow functions fix the
thisreference in inner functions - Extending Array.prototype with
defineProperty - Using classes in JavaScript
- Why use classes over prototypes?
Objectis a global constructor function- Three ways to check for prototype
- Practice makes perfect: the prototype chain
- The
instanceofoperator and object-oriented JavaScript Function,Objectandinstanceof- The Constructor Property
- Chaining constructors for an object with
call - Practice makes perfect: let’s build a prototype chain!
- Using
Object.createto add prototypes for objects - Static Methods
- Public and Private Methods
- Inheritance using
extendsandsuper - Monkey-patching
- By-passing inheritance using mixins
- Shallow copy and deep copy
- Addendum: A non-trivial OOP example using classes in JavaScript
- Another example
Chapter 22: Errors, debugging, and strict mode
- Throwing errors in JavaScript
- The
try...catch...finallystatement - Throwing the error
- Catching the error
- As soon as an error is thrown, the try block is DONE
- The
finallystatement - Catching all types of errors
- Custom error messages
- Stack Trace
- Using
console.trace() - Traces and function names
- Debugging with
console.trace() - Stack tracing Error constructors
- Strict mode
- 1. All variables must be declared
- 2. Non-writable global variables cannot be used as a variable names
- 3. Duplicate parameters are not allowed
- 4. Functions must be declared in the global scope or directly inside a function
- 5. The
withstatement is forbidden - 6. Decimals with leading zeros are not allowed
- 7. Not allowed to set or delete immutable properties
- BROWSER SNIFFING
- FEATURE SNIFFING
- DEBUGGING JAVASCRIPT
- Debugging with console and alert
- The quickest way to run the built-in devtools debugger
- Pausing on exceptions
- What is a breakpoint?
- Local scope, global scope, and closures in the debugger
- Using the
debuggerkeyword to programmatically set a breakpoint - Editing breakpoints (watching expressions)
- Working with different types of breakpoints
- Step over, step into, step out, and step
- Debugging with the Step into next function call button
- The Deactivate / Activate breakpoints button
- Inspecting the call stack
- Debugging with Chrome devtools Performance panel
- Blackboxing scripts
- JavaScript sourcemaps
- AVOIDING THE NEED TO DEBUG
- LINTERS AND CODE EDITORS
- Installing ESLint with npm
Chapter 23: Modular JavaScript
- What problems does modular JavaScript code solve
- How to install Node and npm on our machine?
- Adding a new project with npm
- Adding actual code to our npm project
- Collaborating in a team using npm
- Using npm scripts and task runners
- Modular JavaScript
- We can’t use
requirein the browser - What is a module bundler?
- Working with ES6 modules (ESM syntax)
- Working with ES6 modules in the browser
- Running an Express server
- How does webpack work?
- Adding webpack to our JavaScript programs
- Understanding the structure of the
node_modulesfolder - Working with npm scripts
- Running files with Node.js using npm scripts
- Running webpack on our project’s files
- Running webpack on vanilla JavaScript modules
- Compiling JavaScript modules to a custom output with webpack
- Specifying custom entry file in the webpack configuration
- Building HTML files with webpack
- The
moduleobject - Exporting various values with
module.exports - How to set up webpack with html files
- Conclusion
Chapter 24: JavaScript Object Notation (JSON)
- What is JSON
- Why is JSON so popular?
- What does valid JSON look like
- Using JSON tools for increased productivity
- Looping over JSON objects
- Making AJAX requests to get JSON data from the web
- An alternative solution to printing JSON data to screen
- Transforming objects to arrays to deal with JSON data, explanation
- Making AJAX requests to get JSON data from our own computer
- Printing data to screen using nested for loops
- Running JSON.parse on
undefinedvs running it onnull - Conclusion
Chapter 25: Asynchronous JavaScript
- What are blocking operations?
- The XMLHttpRequest constructor
- The anatomy of an XHR request
- What are callbacks?
- Let’s build callbacks from ground up
- Functions are first-class citizens
- Passing strings to functions
- Passing function invocations to functions
- Higher-order functions take or return other functions
- Passing named function declarations to other functions
- Passing anonymous functions to higher order functions
- Understanding callbacks in general
- Callbacks are everywhere
- Running a callback function when a button is clicked
- Using callbacks to run XHR requests
- Asynchronous XHR inside a callback function
- The biggest difference between regular functions and asynchronous (callback) functions
- The problem with callbacks
- Callbacks and the inversion of control
- Callback hell aka The Pyramid of Doom
- A more realistic example of callback hell
- Intermission: where we’re at
- Dealing with errors in callbacks
- Dealing with errors in callbacks without using a third-party library like jQuery
- Dealing with callback hell
- Promises
- Working with promises using the
fetch()method - Understanding promises
- What is the contents of
[[]]? - Dealing with rejected promises using the
catch()method - Error handling in promises with
catch()andfinally() - Dealing with rejected promises by passing the second argument to the
then()method - How do the functions deferred by a promise get back onto the call stack?
- A few important conclusions regarding promises
- Working with Promise.all
- Iterators and Generators
- Iterators perform work on streams of data
- The iteration protocol
- Generators
- An instance of GeneratorFunction is an iterable object!
- Returning values dynamically with
yield - Combining generators with promises
- Async/Await
- Observables
- Revisiting the iterator patern
- The observer pattern
- Observables in vanilla JS
- Revising observables
- Subscribing to an observable data stream with RxJS
