Leanpub Header

Skip to main content

A better way to learn JavaScript - Built-in Objects

Save Yourself From Another 1000 Hours of Trial and Error Experiences!

Save yourself from 1000 hours of trial and error experiences! Stop feeling overwhelmed! Let this book take you from a newbie to a confident JavaScript developer in a matter of weeks! I'm aiming for this book series to be the best resource on learning JavaScript.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
About

About

About the Book

This book is a second in the series of 5 books on JavaScript.

In Book 1 we learned a lot about JavaScript. In Book 2, we "backfill" the wholes in our knowledge by having a detailed, in-depth look at all the built-in objects in JavaScript.

Understanding all the available methods and properties on built-in objects will do wonders for our confidence as JS developers.

Once you read this book, you can rest assured that whatever JS code comes your way, you'll know where it's coming from and how it works.

Books 1 and 2 are a solid foundation for working with some real-life code, with a lot of code snippets, and specific use cases. This is what Book 3 is about.

However, at the end of Book 2, we'll have a large section with all the code snippets extracted from both Books 1 and 2 (currently at about 90 code snippets, but as this book gets updated, by the end it should have at least 300 code snippets).

Both Books 1 and 2 aim to "draw the map of JavaScript", and are indeed a Better Way to Learn JS, because they are like a story about JavaScript that unwinds right before you.

Join me on this journey!

Share this book

Categories

Installments completed

2 / 5

Price

Pick Your Price...

Minimum price

$19.00

$29.00

You pay

$29.00

Author earns

$23.20
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Ajdin Imsirovic

Ajdin Imsirovic is a full-stack web developer who has published several courses (way back in 2015) on the subject of web design and web development. 

Before self-publishing books on Leanpub, he authored four books on front-end development for Packt Publishing:

  1. Vue CLI 3 Quick Start Guide (Build and maintain Vue.js applications quickly with the standard CLI), May 2019
  2. Vue.js Quick Start Guide (Learn how to build amazing and complex reactive web applications easily using Vue.js), October 2018
  3. Elm Web Development (An introductory guide to building functional web apps using Elm), March 2018
  4. Bootstrap 4 Cookbook (Over 75 recipes to help you build elegant and responsive web applications with Bootstrap 4), June 2017

Additionally, he's published a number of books on the Leanpub platform, specifically:

  1. A Better Way to Learn JavaScript - The Basics: https://bit.ly/abwtljs1
  2. A Better Way to Learn JavaScript - Built-in Objects: https://bit.ly/abwtljs2
  3. A Better Way to Learn JavaScript - Useful Snippets: https://bit.ly/abwtljs3
  4. A Better Way to Learn JavaScript - Mini Apps: https://bit.ly/abwtljs4
  5. A Better Way to Learn JavaScript - Advanced JavaScript: https://bit.ly/abwtljs5
  6. Angular From Scratch: https://bit.ly/ai-afs
  7. Vue.js From Scratch: https://bit.ly/ai-vfs
  8. React from Scratch: https://leanpub.com/react-from-scratch
  9. Building Amazing Layouts - Learn the Basics of HTML5, CSS3, and Bootstrap 5: https://bit.ly/bldamzlyts1
  10. Building Amazing Layouts - Bootstrap 5 Layouts in Depth: https://bit.ly/bldamzlyts2
Leanpub Podcast

Episode 208

An Interview with Ajdin Imsirovic

Contents

Table of Contents

Introduction

Chapter 1: An overview of standard built-in objects

Chapter 2: The Object object

  1. The Object object
  2. The Object object’s methods and properties
  3. Static methods on the Object object
  4. Object object’s static “create” methods
  5. Object object’s static “read” methods
  6. Object object’s static “update” methods
  7. Object object’s static “freeze” methods
  8. Object object’s instance properties and methods
  9. Object object’s instance properties
  10. Object object’s instance methods
  11. Object object’s deprecated instance methods
  12. Object object’s “checker” instance methods
  13. Object object’s “conversion” instance methods

Chapter 3: The Function object

  1. The Function object
  2. Function.prototype.apply()
  3. Whip up “Array.max” method with Function.prototype.apply()
  4. Function.prototype.call()
  5. Function.prototype.bind()
  6. Why bind a function?
  7. Use bind() to cement the context of this
  8. Use bind() to partially apply a function
  9. Use bind() to pass context to setTimeout()
  10. Use bind() for invocation shortcuts
  11. Function.prototype.toString()

Chapter 4: The Boolean object

  1. The Boolean object
  2. The Boolean constructor and boolean primitives behave differently
  3. Don’t convert a non-boolean using the constructor!
  4. Built-in Boolean object’s instance methods

Chapter 5: The Symbol object

  1. The Symbol object
  2. There’s no “shorthand syntax” for the symbol primitive
  3. Symbol() is a factory function
  4. Why is the Symbol() not a true constructor?
  5. Using a symbol’s optional description argument
  6. How to get a symbol’s description?
  7. Why Symbols in ES6?
  8. How to add a symbol to an object literal?
  9. Getting the value of a symbol key from an object
  10. Symbols are excluded from for...in loops
  11. Pseudo-hidden properties on objects are made possible by symbols
  12. Why symbols in ES6, again?
  13. Why symbols are not truly hidden?
  14. Symbols are skipped in JSON conversions
  15. Symbols can be used to avoid code collisions
  16. Symbols can be used to fix ENUM lists
  17. Use symbols as metadata storage
  18. The global symbol registry
  19. The difference between local and global symbols
  20. Well-known symbols
  21. Conclusion

Chapter 6: Built-in collection objects: Array

  1. The Array object
  2. The Array[@@species] accessor
  3. The Array.prototype[@@iterator]() instance method
  4. The Array.prototype[@@unscopables] instance property
  5. The Array.from() static method
  6. The Array.of() static method
  7. The Array.prototype.entries() instance method
  8. The Array.prototype.keys() instance method
  9. The Array.prototype.values() instance method
  10. The Array.prototype.findIndex() instance method
  11. The Array.prototype.lastIndexOf() instance method
  12. The Array.prototype.toLocaleString() instance method
  13. The Array.prototype.toString() instance method
  14. The Array.prototype.reduceRight() instance method

Chapter 7: Built-in collection objects: typed array objects

  1. Why typed arrays in JS?
  2. The immutability of Blob
  3. Extracting Blob slices

Chapter 8: Built-in collection objects: maps, sets, weak maps, weak sets, and arguments

  1. The Map object
  2. The Set object
  3. The WeakMap object
  4. The WeakSet object
  5. The arguments array-like object

Chapter 9: Error objects

  1. How to throw errors in JS?
  2. How to catch errors in JS gracefully?
  3. How to customize error messages in JS?
  4. What’s a stack trace?
  5. Strict mode and errors
  6. Browser sniffing and errors
  7. Errors and debugging

Chapter 10: Async-related and JSON-related objects

  1. An overview of built-in async-related objects, their properties, and methods
  2. The Promise() constructor and the then() instance method
  3. Wrapping methods into promise objects
  4. Passing one more promise to the resolveFn
  5. The Promise.all(iterable) static method
  6. The Promise.allSettled(iterable) static method
  7. The Promise.any(iterable) static method
  8. The Promise.race(iterable) static method
  9. The Promise.reject(reason) static method
  10. The Promise.resolve(value) static method
  11. The GeneratorFunction() and AsyncFunction()
  12. Using Generator.prototype.next()
  13. Using Generator.prototype.return()
  14. Using Generator.prototype.throw()
  15. The JSON object
  16. JSON.parse(text[, reviver])
  17. JSON.stringify(value[, replacer[, space]])
  18. The ArrayBuffer object
  19. The SharedArrayBuffer object
  20. The Atomics object
  21. The DataView object

Chapter 11: String, number, date, and internationalization objects

  1. String object’s built-in methods and properties
  2. “CREATE” string methods
  3. “READ location” string methods
  4. “READ inclusion” string methods
  5. “READ string comparison” string methods
  6. “UPDATE join and split” string methods
  7. “UPDATE spacing” string methods
  8. “UPDATE letter casing” string methods
  9. DELETE
  10. The String.prototype regex (pattern-matching) methods
  11. Number object’s built-in methods and properties
  12. Date object’s built-in methods and properties
  13. Intl object’s built-in methods and properties

Chapter 12: Regular expressions in JavaScript

  1. What is a regular expression in JavaScript?
  2. Regular expression literal
  3. Check if an object is of RegExp type
  4. RegExp constructor function
  5. RegExp modifiers (aka “pattern flags”)
  6. String.prototype.split() with RegExp
  7. String.prototype.replace() with RegExp
  8. String.prototype.search with RegExp
  9. String.prototype.match with RegExp
  10. String.prototype.matchAll() and String.prototype.replaceAll()
  11. Character classes (aka character sets)
  12. Combining character classes
  13. Negating character classes
  14. Using the pipe for optional matching
  15. Metacharacters
  16. Regular expressions quantifiers
  17. RegExp assertions

Chapter 13: Reflection and proxy objects (metaprogramming in JS)

  1. The Reflect object
  2. The Proxy object
  3. Specifing a proxy handler object
  4. An example of each trap method
  5. Back to the Reflect object
  6. Proxy (trap) invariants
  7. Revocable proxies
  8. Building a proxy of a proxy

Chapter 14: Web assembly objects

Chapter 15: Revision

  1. 1. Build a new object and specify its prototype
  2. 2. Copy enumerable own properties from one object to another
  3. 3. Copy enumerable own properties from multiple objects into a single object
  4. 4. Convert an array of arrays into an object
  5. 5. Covert an object into an array of arrays
  6. 6. Log out an object’s members as key-value pairs
  7. 7. Inspect an objects own property descriptor(s)
  8. 8. An alternative way of counting the number of members in an array
  9. 9. Count the number of members in an associative array
  10. 10. Find the number of own properties that an object has
  11. 11. Get values out of an associative array
  12. 12. On an object, add a named property with property descriptor editability
  13. 13. On an object, add multiple named properties with property descriptor editability
  14. 14. Prevent an object’s shallow properties from being deleted or changed (freeze an object)
  15. 15. Freeze an array
  16. 16. Prevent exensions of object’s properties but allow for deletions
  17. 17. Prevent extensions and deletions of an object’s properties
  18. 18. Define getters and setters on an object’s property
  19. 19. Define getters and setters directly on an object literal
  20. 20. Inspect getters and setters on an object’s specific property
  21. 21. Check if an object has an own property and return a boolean of the result
  22. 22. Check if an object’s own property’s property is enumerable
  23. 23. Check if an object is a prototype of another object
  24. 24. Call a method to check the number of arguments a function expects
  25. 25. Log out all the arguments passed to a function call using the arguments array-like object
  26. 26. Apply an object as the this value of another object’s method
  27. 27. Pass arguments to a function using the apply() method without specifying the this argument
  28. 28. Concatenate any number of arguments using the built-in “arguments” array-like variable
  29. 29. Sum up any number of arguments using the built-in “arguments” array-like variable
  30. 30. Concatenate the values of all the object’s properties, using another object’s joiner function
  31. 31. Borrow Math.max() static method and apply it on an array of numbers to get the highest number
  32. 32. Borrow Math.min() static method and apply it on an array of numbers to get the lowest number
  33. 33. Use apply to monkey patch (extend) a built-in object as a polyfill on an older browser
  34. 34. Borrow a method from one object to another object using call() without arguments
  35. 35. Borrow a method from one object to another object using call() with arguments
  36. 36. Use apply() instead of call() in a given code snippet
  37. 37. Prove that every function call is calling the call() method in the background
  38. 38. Chain constructors with the call() method
  39. 39. Fix the problem of keeping the context of this in a nested function
  40. 40. Why bind a function?
  41. 41. Use bind() to cement the context of this
  42. 42. Use bind() to partially apply a function
  43. 43. Use bind() to pass context to setTimeout()
  44. 44. Use bind() to make invocation shortcut on Array.prototype.slice()
  45. 45. Set a symbol as an object’s key
  46. 46. Add a symbol to an object literal
  47. 47. Prove that each symbol is unique
  48. 48. Check if a variable is of type symbol
  49. 49. Log out a symbol’s description
  50. 50. Why were symbols added to ES6?
  51. 51. Get the value of a symbol key from an object
  52. 52. Prove that symbols are excluded from for..in loops
  53. 53. Add a symbol to an object without storing the symbol in a variable beforehand
  54. 54. Prove that symbols are skipped in JSON conversion
  55. 55. What will happen if we try to reassign an existing symbol property in an object
  56. 56. Use a symbol to fix an ENUM list
  57. 57. Show how to use a symbol as a metadata storage
  58. 58. Show a use case for the Array[@@species] accessor
  59. 59. Reimplement a “regular” iterator with Array.prototype[@@iterator]()
  60. 60. Build an iterator that iterates over every even member of an array
  61. 61. Build an iterator that iterates over every odd member of an array
  62. 60. Convert a Set to an Array
  63. 61. Use a mapping function with Array.from()
  64. 62. Convert a string to an Array with Array.of()
  65. 63. Iterate over an array with Array.prototype.entries
  66. 64. Iterate over an array and break out of a loop based on a condition, using Array.prototype.entries
  67. 65. Split an array into a series of arrays using Array.prototype.entries
  68. 66. Split an array into a series of objects using Array.prototype.entries
  69. 67. Push array keys into a separate array using Array.prototype.keys
  70. 68. Print array values using Array.prototype.values
  71. 69. Find index of a matching member of array or return -1 with Array.prototype.findIndex
  72. 70. Search for a match from the end of array with Array.prototype.lastIndexOf
  73. 71. Localize a decimal number as price with Array.prototype.toLocaleString
  74. 72. Concatenate all args using Array.prototype.reduce
  75. 73. Concatenate all args using Array.prototype.reduceRight
  76. 74. How to throw errors in JS?
  77. 75. How to catch errors in JS gracefully?
  78. 76. How to customize error messages in JS?
  79. 77. Show that the Promise() constructor must take a callback function
  80. 78. Why no error is thrown when we call then() on a promise, without passing any functions to then()
  81. 79. Build a promise that randomly fetches data from coindesk or throws an error, and catches it
  82. 80. Display a message at the end of a promise regardless of whether it succeeds or fails
  83. 81. Deal with potential errors by passing the second argument to the then() call in a promise
  84. 82. “Promisify” a method that does not usually return a promise object
  85. 83. Log out a sentence from inside a promise
  86. 84. Send a notification of a promise successfully fulfilled
  87. 85. Give an example of using Promise.reject()
  88. 86. Give an example of using Promise.resolve()
  89. 87. Return the GeneratorFunction() constructor
  90. 88. Return the AsyncFunction() constructor
  91. 89. Iterate values using Generator.prototype.next()
  92. 90. Iterate an array using Generator.prototype.next()
  93. 91. Send values to the generator
  94. 92. Show that the Generator.prototype.return() finishes the generator

The Leanpub 60 Day 100% Happiness Guarantee

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

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

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) and EPUB (for phones, tablets and 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. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub