Loading topic
let and const, write and call functions, and run code in a browser console or Node.js. It covers how JavaScript decides which operator applies first when an expression contains several of them.2 min read-, *, and / always convert their operands to numbers. The + operator is the exception. Depending on its operands, + either adds numbers or joins strings, and choosing between t2 min readlet and const, and can run code in a browser console or Node.js. It builds on the earlier chapter on type coercion, where ToBoolean was introduced as one of the conversion steps.2 min read===) works and how JavaScript's conversion steps work: ToPrimitive, ToNumber, and ToString. Loose equality (==) uses those conversions. Before it compares two values, it may change one or both of them, so it follows a fixed algorithm rat2 min read=== works and that you can run snippets in Node.js or a browser console. The previous chapters covered strict and loose equality. JavaScript actually defines three "same value" algorithms, and different built-in features use different ones.2 min read===, ==, and Object.is work. It covers the four values where those operators give unexpected answers. Most equality bugs in real code involve one of these four values.1 min read===) works with primitives. It also assumes you know that == converts its operands to primitives with ToPrimitive. Here you will see what both operators do when the operands are objects, arrays, or functions.2 min read== handles null. The relational operators <, >, <=, and >= also convert their operands. They follow their own algorithm, though, and it differs from the one == uses.2 min readtrue or false. In JavaScript, && and || return one of their operands. Only ! always returns a boolean.2 min read|| and && return one of their operands, and which values are falsy. It also assumes you know that null and undefined count as "missing" values.2 min read?? falls back only on null and undefined, and that you have read about short-circuit evaluation with && and ||.2 min read||, &&, and ?? short-circuit, and how + decides between addition and concatenation. Both topics come up again here, because assignment operators reuse those exact rules.2 min read== and === treat different types. Bitwise operators show up less often than the others, but they follow conversion rules that can catch you out. BigInt changes those rules again.2 min read