A better way to learn JavaScript - Built-in Objects
A better way to learn JavaScript - Built-in Objects
Save Yourself From Another 1000 Hours of Trial and Error Experiences!
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!
Bundles that include this book
Table of Contents
- Introduction
- Chapter 1: An overview of standard built-in objects
-
Chapter 2: The
Object
object-
The
Object
object -
The
Object
object’s methods and properties -
Static methods on the
Object
object -
Object
object’s static “create” methods -
Object
object’s static “read” methods -
Object
object’s static “update” methods -
Object
object’s static “freeze” methods -
Object
object’s instance properties and methods -
Object
object’s instance properties -
Object
object’s instance methods -
Object
object’s deprecated instance methods -
Object
object’s “checker” instance methods -
Object
object’s “conversion” instance methods
-
The
-
Chapter 3: The
Function
object-
The
Function
object -
Function.prototype.apply()
-
Whip up “Array.max” method with
Function.prototype.apply()
-
Function.prototype.call()
-
Function.prototype.bind()
- Why bind a function?
-
Use
bind()
to cement the context ofthis
-
Use
bind()
to partially apply a function -
Use
bind()
to pass context tosetTimeout()
-
Use
bind()
for invocation shortcuts -
Function.prototype.toString()
-
The
-
Chapter 4: The
Boolean
object-
The
Boolean
object -
The
Boolean
constructor and boolean primitives behave differently - Don’t convert a non-boolean using the constructor!
-
Built-in
Boolean
object’s instance methods
-
The
-
Chapter 5: The
Symbol
object-
The
Symbol
object - There’s no “shorthand syntax” for the symbol primitive
-
Symbol()
is a factory function -
Why is the
Symbol()
not a true constructor? -
Using a symbol’s optional
description
argument - How to get a symbol’s description?
- Why Symbols in ES6?
- How to add a symbol to an object literal?
- Getting the value of a symbol key from an object
-
Symbols are excluded from
for...in
loops - Pseudo-hidden properties on objects are made possible by symbols
- Why symbols in ES6, again?
- Why symbols are not truly hidden?
- Symbols are skipped in JSON conversions
- Symbols can be used to avoid code collisions
- Symbols can be used to fix ENUM lists
- Use symbols as metadata storage
- The global symbol registry
- The difference between local and global symbols
- Well-known symbols
- Conclusion
-
The
-
Chapter 6: Built-in collection objects:
Array
-
The
Array
object -
The
Array[@@species]
accessor -
The
Array.prototype[@@iterator]()
instance method -
The
Array.prototype[@@unscopables]
instance property -
The
Array.from()
static method -
The
Array.of()
static method -
The
Array.prototype.entries()
instance method -
The
Array.prototype.keys()
instance method -
The
Array.prototype.values()
instance method -
The
Array.prototype.findIndex()
instance method -
The
Array.prototype.lastIndexOf()
instance method -
The
Array.prototype.toLocaleString()
instance method -
The
Array.prototype.toString()
instance method -
The
Array.prototype.reduceRight()
instance method
-
The
-
Chapter 7: Built-in collection objects: typed array objects
- Why typed arrays in JS?
-
The immutability of
Blob
- Extracting Blob slices
-
Chapter 8: Built-in collection objects: maps, sets, weak maps, weak sets, and arguments
-
The
Map
object -
The
Set
object -
The
WeakMap
object -
The
WeakSet
object -
The
arguments
array-like object
-
The
-
Chapter 9: Error objects
- How to throw errors in JS?
- How to catch errors in JS gracefully?
- How to customize error messages in JS?
- What’s a stack trace?
- Strict mode and errors
- Browser sniffing and errors
- Errors and debugging
-
Chapter 10: Async-related and JSON-related objects
- An overview of built-in async-related objects, their properties, and methods
-
The
Promise()
constructor and thethen()
instance method - Wrapping methods into promise objects
-
Passing one more promise to the
resolveFn
-
The
Promise.all(iterable)
static method -
The
Promise.allSettled(iterable)
static method -
The
Promise.any(iterable)
static method -
The
Promise.race(iterable)
static method -
The
Promise.reject(reason)
static method -
The
Promise.resolve(value)
static method -
The
GeneratorFunction()
andAsyncFunction()
-
Using
Generator.prototype.next()
-
Using
Generator.prototype.return()
-
Using
Generator.prototype.throw()
-
The
JSON
object -
JSON.parse(text[, reviver])
-
JSON.stringify(value[, replacer[, space]])
-
The
ArrayBuffer
object -
The
SharedArrayBuffer
object -
The
Atomics
object -
The
DataView
object
-
Chapter 11: String, number, date, and internationalization objects
-
String
object’s built-in methods and properties - “CREATE” string methods
- “READ location” string methods
- “READ inclusion” string methods
- “READ string comparison” string methods
- “UPDATE join and split” string methods
- “UPDATE spacing” string methods
- “UPDATE letter casing” string methods
- DELETE
-
The
String.prototype
regex (pattern-matching) methods -
Number
object’s built-in methods and properties -
Date
object’s built-in methods and properties -
Intl
object’s built-in methods and properties
-
-
Chapter 12: Regular expressions in JavaScript
- What is a regular expression in JavaScript?
- Regular expression literal
- Check if an object is of RegExp type
- RegExp constructor function
- RegExp modifiers (aka “pattern flags”)
-
String.prototype.split()
withRegExp
-
String.prototype.replace()
withRegExp
-
String.prototype.search
withRegExp
-
String.prototype.match
withRegExp
-
String.prototype.matchAll()
andString.prototype.replaceAll()
- Character classes (aka character sets)
- Combining character classes
- Negating character classes
- Using the pipe for optional matching
- Metacharacters
- Regular expressions quantifiers
- RegExp assertions
-
Chapter 13: Reflection and proxy objects (metaprogramming in JS)
-
The
Reflect
object -
The
Proxy
object - Specifing a proxy handler object
- An example of each trap method
-
Back to the
Reflect
object - Proxy (trap) invariants
- Revocable proxies
- Building a proxy of a proxy
-
The
- Chapter 14: Web assembly objects
-
Chapter 15: Revision
- 1. Build a new object and specify its prototype
- 2. Copy enumerable own properties from one object to another
- 3. Copy enumerable own properties from multiple objects into a single object
- 4. Convert an array of arrays into an object
- 5. Covert an object into an array of arrays
- 6. Log out an object’s members as key-value pairs
- 7. Inspect an objects own property descriptor(s)
- 8. An alternative way of counting the number of members in an array
- 9. Count the number of members in an associative array
- 10. Find the number of own properties that an object has
- 11. Get values out of an associative array
- 12. On an object, add a named property with property descriptor editability
- 13. On an object, add multiple named properties with property descriptor editability
- 14. Prevent an object’s shallow properties from being deleted or changed (freeze an object)
- 15. Freeze an array
- 16. Prevent exensions of object’s properties but allow for deletions
- 17. Prevent extensions and deletions of an object’s properties
- 18. Define getters and setters on an object’s property
- 19. Define getters and setters directly on an object literal
- 20. Inspect getters and setters on an object’s specific property
- 21. Check if an object has an own property and return a boolean of the result
- 22. Check if an object’s own property’s property is enumerable
- 23. Check if an object is a prototype of another object
- 24. Call a method to check the number of arguments a function expects
-
25. Log out all the arguments passed to a function call using the
arguments
array-like object -
26. Apply an object as the
this
value of another object’s method -
27. Pass arguments to a function using the
apply()
method without specifying the this argument - 28. Concatenate any number of arguments using the built-in “arguments” array-like variable
- 29. Sum up any number of arguments using the built-in “arguments” array-like variable
-
30. Concatenate the values of all the object’s properties, using another object’s
joiner
function -
31. Borrow
Math.max()
static method and apply it on an array of numbers to get the highest number -
32. Borrow
Math.min()
static method and apply it on an array of numbers to get the lowest number - 33. Use apply to monkey patch (extend) a built-in object as a polyfill on an older browser
-
34. Borrow a method from one object to another object using
call()
without arguments -
35. Borrow a method from one object to another object using
call()
with arguments -
36. Use
apply()
instead ofcall()
in a given code snippet -
37. Prove that every function call is calling the
call()
method in the background -
38. Chain constructors with the
call()
method -
39. Fix the problem of keeping the context of
this
in a nested function - 40. Why bind a function?
-
41. Use
bind()
to cement the context of this -
42. Use
bind()
to partially apply a function -
43. Use
bind()
to pass context tosetTimeout()
-
44. Use
bind()
to make invocation shortcut onArray.prototype.slice()
- 45. Set a symbol as an object’s key
- 46. Add a symbol to an object literal
- 47. Prove that each symbol is unique
-
48. Check if a variable is of type
symbol
- 49. Log out a symbol’s description
- 50. Why were symbols added to ES6?
- 51. Get the value of a symbol key from an object
-
52. Prove that symbols are excluded from
for..in
loops - 53. Add a symbol to an object without storing the symbol in a variable beforehand
- 54. Prove that symbols are skipped in JSON conversion
- 55. What will happen if we try to reassign an existing symbol property in an object
- 56. Use a symbol to fix an ENUM list
- 57. Show how to use a symbol as a metadata storage
-
58. Show a use case for the
Array[@@species]
accessor -
59. Reimplement a “regular” iterator with
Array.prototype[@@iterator]()
- 60. Build an iterator that iterates over every even member of an array
- 61. Build an iterator that iterates over every odd member of an array
-
60. Convert a
Set
to anArray
-
61. Use a mapping function with
Array.from()
-
62. Convert a
string
to anArray
withArray.of()
-
63. Iterate over an array with
Array.prototype.entries
-
64. Iterate over an array and break out of a loop based on a condition, using
Array.prototype.entries
-
65. Split an array into a series of arrays using
Array.prototype.entries
-
66. Split an array into a series of objects using
Array.prototype.entries
-
67. Push array keys into a separate array using
Array.prototype.keys
-
68. Print array values using
Array.prototype.values
-
69. Find index of a matching member of array or return -1 with
Array.prototype.findIndex
-
70. Search for a match from the end of array with
Array.prototype.lastIndexOf
-
71. Localize a decimal number as price with
Array.prototype.toLocaleString
-
72. Concatenate all args using
Array.prototype.reduce
-
73. Concatenate all args using
Array.prototype.reduceRight
- 74. How to throw errors in JS?
- 75. How to catch errors in JS gracefully?
- 76. How to customize error messages in JS?
-
77. Show that the
Promise()
constructor must take a callback function -
78. Why no error is thrown when we call
then()
on a promise, without passing any functions tothen()
- 79. Build a promise that randomly fetches data from coindesk or throws an error, and catches it
- 80. Display a message at the end of a promise regardless of whether it succeeds or fails
-
81. Deal with potential errors by passing the second argument to the
then()
call in a promise - 82. “Promisify” a method that does not usually return a promise object
- 83. Log out a sentence from inside a promise
- 84. Send a notification of a promise successfully fulfilled
-
85. Give an example of using
Promise.reject()
-
86. Give an example of using
Promise.resolve()
-
87. Return the
GeneratorFunction()
constructor -
88. Return the
AsyncFunction()
constructor -
89. Iterate values using
Generator.prototype.next()
-
90. Iterate an array using
Generator.prototype.next()
- 91. Send values to the generator
-
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.
See full terms
Do Well. Do Good.
Authors have earned$11,580,376writing, 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
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
Top Books
SignalR on .NET 6 - the Complete Guide
Fiodar SazanavetsLearn everything there is to learn about SignalR and how to integrate it with the latest .NET 6 and C# 10 features. Learn how to connect any type of client to SignalR, including plain WebSocket client. Learn how to build interactive applications that can communicate with each other in real time without making excessive calls.
The easiest way to learn design patterns
Fiodar SazanavetsLearn design patterns in the easiest way possible. You will no longer have to brute-force your way through each one of them while trying to figure out how it works. The book provides a unique methodology that will make your understanding of design patterns stick. It can also be used as a reference book where you can find design patterns in seconds.
Agile Testing Condensed Japanese Edition
Yuya Kazama, Janet Gregory, and Lisa CrispinJanet GregoryとLisa Crispinによる2019年9月発行の書籍『Agile Testing Condensed』の日本語翻訳版です。アジャイルにおいてどのような考えでテストを行うべきなのか簡潔に書かれています!
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
Functional event-driven architecture: Powered by Scala 3
Gabriel VolpeExplore the event-driven architecture (EDA) in a purely functional way, mainly powered by Fs2 streams in Scala 3!
Leverage your functional programming skills by designing and writing stateless microservices that scale, powered by stateful message brokers.
Tech Giants in Healthcare
Dr. Bertalan MeskoThis comprehensive guide, Tech Giants in Healthcare, clarifies how and why big tech companies step into healthcare, and breaks it down from one market player to the other in what direction they are going, what tools they are using and what horizons they have in front of them.
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
Recipes for Decoupling
Matthias NobackCCIE Service Provider Version 4 Written and Lab Exam Comprehensive Guide
Nicholas RussoThe service provider landscape has changed rapidly over the past several years. Networking vendors are continuing to propose new standards, techniques, and procedures for overcoming new challenges while concurrently reducing costs and delivering new services. Cisco has recently updated the CCIE Service Provider track to reflect these changes; this book represents the author's personal journey in achieving that certification.
The BDD Books - Discovery (Japanese Edition)
Gáspár Nagy, Seb Rose, and Yuya Kazamaウクライナ難民を支援 - 2022年5月末まで延長!
この本の売り上げの50%は、 https://unicef.hu/veszhelyzet-ukrajnaban と https://int.depaulcharity.org/fundraising-for-depaul-ukraine/ に寄付されます。
本書籍は、振る舞い駆動開発(Behavior Driven Development, BDD)や受け入れテスト駆動開発(Acceptance Test-Driven Development, ATDD)の発見フェーズを最大限に活用する方法を提供します。
Top Bundles
- #1
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon... - #2
Practical FP in Scala + Functional event-driven architecture
2 Books
Practical FP in Scala (A hands-on approach) & Functional event-driven architecture, aka FEDA, (Powered by Scala 3), together as a bundle! The content of PFP in Scala is a requirement to understand FEDA so why not take advantage of this bundle!? - #3
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #5
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #6
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #8
Modern C++ Collection
3 Books
Get All about Modern C++C++ Standard Library, including C++20Concurrency with Modern C++, including C++20C++20Each book has about 200 complete code examples. Updates are included. When I update one of the books, you immediately get the updated bundle. You can expect significant updates to each new C++ standard (C++23, C++26, .. ) and also... - #9
Linux Administration Complet
4 Books
Ce lot comprend les quatre volumes du Guide Linux Administration :Linux Administration, Volume 1, Administration fondamentale : Guide pratique de préparation aux examens de certification LPIC 1, Linux Essentials, RHCSA et LFCS. Administration fondamentale. Introduction à Linux. Le Shell. Traitement du texte. Arborescence de fichiers. Sécurité...