Loading topic
let and const, write and call functions, and run snippets in a browser console or Node.js. You should also be familiar with the basic arithmetic and comparison operators. Later chapters cover how each operator converts its operands. Here the qu4 min readlet and const, know the JavaScript primitive types, and can run code in a browser console or Node.js. It also builds on the previous chapter's coercion rules, especially ToPrimitive and ToNumber.4 min readif statements and functions, and the basic idea of type coercion from the earlier chapter. Here we look at one specific conversion, ToBoolean. It decides whether a value counts as "true enough" when JavaScript needs a4 min read=== operator answers one question: are these two values the same type and the same value? It never converts either operand first. That makes its results easy to predict, which is why most style guides make it the default.4 min read===) works and have met the main coercion steps: ToPrimitive, ToNumber, and ToString. You should also be comfortable running snippets in Node.js or a browser console. The goal is to replace guesswork about == with a short algorithm that 4 min read=== works and how == converts its operands, which earlier chapters covered. You should also be comfortable running snippets in Node.js or a browser console.4 min read=== and == work, what Object.is does, and how ToNumber converts values. It looks at the four values that break the usual rules. NaN is not equal to itself. -0 hides behind 0. null and undefined each follow their own conversion rules. You wi4 min read=== and == treat primitives, as covered in the earlier chapters on strict and loose equality. It also assumes you are comfortable with object and array literals and can run code in Node.js or a browser console.4 min read<, >, <= and >= look simple. Their conversion rules differ from both === and ==, though, so the results can surprise you. This chapter shows the algorithm behind these operators and explains why null >= 0 is true while null == 0 is false. It also covers h4 min read&& and || do not always return true or false. They return one of their operands, an4 min read|| and && pick one of their operands and short-circuit, which the previous chapter covered. It also assumes you know which values are falsy and how null and undefined behave in comparisons. The topic here is the nullish coalescing operator, ??. It supplies4 min read?? falls back only on null and undefined, and that you can tell nullish values apart from falsy ones. You should also be comfortable with objects, arrays, methods, and this.4 min read||, &&, and ?? short-circuit, and which values count as falsy versus nullish. Both topics were covered in earlier chapters. Here we look at how assignment builds on those operators. That includes some behavior that is easy to miss: what the assignment expressi4 min readToNumber converts values (from the coercion chapter) and how arithmetic operators treat their operands. Bitwise operators are rare in everyday JavaScript. They do show up in permission flags, hashing, binary protocols, and old code that relies on tricks li3 min read== differs from ===, and how Object.is and SameValueZero treat special values. It also assumes you can run code in Node.js or a browser console. BigInt is the primitive type for integers of any size. Its3 min read