A Better Way To Learn JavaScript
A Better Way To Learn JavaScript
$14.99
Minimum price
$29.99
Suggested price
A Better Way To Learn JavaScript

This book is 65% complete

Last updated on 2020-05-24

About the Book

This book is based on a tried and tested learning methodology.

This learning methodology will give you the best possible results in the shortest amount of time!

Along the way, you'll learn how to build truly useful apps in JavaScript, which will speed up your workflow and help you with your daily tasks.

About the Author

Ajdin Imsirovic
Ajdin Imsirovic

Ajdin Imsirovic is a developer and designer with over 2 decades of experience on the web.

Table of Contents

  • Introduction
    • The Problem of Learning: Does the World Really Need Another JavaScript Book?
    • What We’re Building
  • Chapter 1: The Absolute Basics
    • A Function is A Machine
    • Generalizing Functions in JavaScript
    • Anonymous functions
    • Conclusions
    • What’s next?
  • Chapter 2: The Quick Prototype App
    • Before We Build the App
    • Building the Quick Prototyper App
    • Using Github to Share our code
    • Updating Our Web Page Dynamically
    • Reinforcing Our Learning With Devtools Snippets
    • Start Building the Quick Prototyper snippet
    • Checking for Equality and Running our Code Conditionally
    • Adding a Second Component to Quick Prototyper
    • Passing Custom Arguments to Our Function Calls Based on User Input
    • Prompting For Multiple Components At a Time
  • Chapter 3: Understanding Events in JavaScript
    • What are Events in JavaScript
    • Inline Event Handlers
    • How JavaScript Deals with Events
    • Stopping Event Propagation
    • Add an Event Handler to our Page Dynamically
    • The Event Object
  • Chapter 4: Improving the UX on Quick Prototyper
    • Adding Buttons To our App
    • Adding the Navbar to our QuickPrototyper
    • List of Updates Made to QuickPrototyperV10
  • Chapter 5: Introducing jQuery
    • Adding the textToEdit and popUpEditor divs
    • Styling the popUpEditor
  • Chapter 6: 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 7: 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 8: Data Types and Constructors
    • Objects VS non-objects
    • Finding the type of primitives using the typeof operator
    • The number type
    • The null type
    • The undefined type
    • The boolean type
    • The bigint type
    • 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
    • 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
    • Conclusion
  • Chapter 9: JavaScript and the Browser
    • “The states of matter” of a web page
    • 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
    • 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
  • Chapter 10: JavaScript and Asynchronicity
    • JavaScript is Single-Threaded and Synchronous
    • Synchronous JavaScript in an Asynchronous Browser
    • Conclusion
  • Chapter 11: 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 and apply
    • Memoization
    • Working with local storage
  • Chapter 12: The Anatomy of a JavaScript Function: 12 Different Ways to Define 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
  • Chapter 13: Understanding arguments and the spread operator
    • How many arguments does a function expect?
    • The arguments variable
    • Can we use the arguments variable with arrow functions?
    • How does the spread operator work in arrow functions?
    • Understanding the arguments local variable in depth
  • Chapter 14: JavaScript Arrays in Depth
    • Using the delete method on an array member
    • Does a value exist in an array?
    • Use Array.length to 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.slice and Array.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” for loop
    • 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 while loop
    • 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.filter followed by Array.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 15: 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 16: 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.create method
    • 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
  • Chapter 17: Working with Objects, Arrays, and JSON
    • Working With JSON Received From The Web
  • Chapter 18: 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 prototype Is 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 this reference in inner functions
    • Extending Array.prototype with defineProperty
    • Using classes in JavaScript
    • Why use classes over prototypes?
    • Object is a global constructor function
    • Three ways to check for prototype
    • Practice makes perfect: the prototype chain
    • The instanceof operator and object-oriented JavaScript
    • Function, Object and instanceof
    • The Constructor Property
    • Chaining constructors for an object with call
    • Practice makes perfect: let’s build a prototype chain!
    • Using Object.create to add prototypes for objects
    • Static Methods
    • Public and Private Methods
    • Inheritance using extends and super
    • Monkey-patching
    • By-passing inheritance using mixins
    • Shallow copy and deep copy
  • Chapter 19: Errors, debugging, and strict mode
    • Throwing errors in JavaScript
    • The try...catch...finally statement
    • Throwing the error
    • Catching the error
    • As soon as an error is thrown, the try block is DONE
    • The finally statement
    • 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 with statement 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 debugger keyword 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 20: 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
  • Chapter 21: 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
    • Reading and writing JSON files with Node.js
    • Working with JSON data
    • How to output JSON to a web page
    • Looping over JSON arrays
    • JSON and local storage
  • Chapter 22: Asynchronous JavaScript
    • What are blocking operations?
    • Asynchronous callbacks
    • The XMLHttpRequest constructor
    • The anatomy of an XHR request
  • Chapter 23: JavaScript Testing
    • Red, green, refactor
    • The benefits of TDD
    • Code coverage and test coverage
    • Unit testing JavaScript with Jest
  • Conclusion: The JavaScript Learning Fractal

Authors have earned$8,922,802writing, publishing and selling on Leanpub,
earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub