getify / You-Dont-Know-JS

A book series on JavaScript. @YDKJS on twitter.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Including bigint example in value type determination

mkermani144 opened this issue · comments

I already searched for this issue.

Edition: 2nd

Book Title: Get started

Chapter: 2

Section Title: Value Type Determination

Question: As you have mentioned about bigints in the chapter, shouldn't you include an example for bigints, indicating that typeof returns "bigint" (and not "number") for bigints? that is,

typeof 42;                  // "number"
typeof 42n;                 // "bigint" <-----------------
typeof "abc";               // "string"
typeof true;                // "boolean"
typeof undefined;           // "undefined"
typeof null;                // "object" -- oops, bug!
typeof { "a": 1 };          // "object"
typeof [1,2,3];             // "object"
typeof function hello(){};  // "function"

Appreciate bringing the issue up. I agree that it would have been a good idea for me to include that line in the book.

But since this book was published 2.5 years ago (with many thousands of copies sold since), I don't see this change as important enough to warrant a deviation of the github content away from the printed book content.