Javascript Weird Parts _hot_ 🚀

Arrow functions don't have their own this —they inherit from the parent scope. That’s often a lifesaver, but it’s another thing to memorize. Every value in JS is inherently truthy or falsy. There are exactly 8 falsy values :

console.log(0.1 + 0.2); // 0.30000000000000004 console.log(0.1 + 0.2 === 0.3); // false Floating-point math. JavaScript uses binary floating point; 0.1 in binary is a repeating fraction (like 1/3 in decimal). It can't be represented exactly. javascript weird parts

JavaScript inserts a semicolon after return . It becomes return; and the object is never reached. Arrow functions don't have their own this —they

const arr = [1, 2, 3]; const obj = { a: 1 }; console.log(arr + arr); // "1,2,31,2,3" (string) console.log(arr + obj); // "1,2,3[object Object]" There are exactly 8 falsy values : console

JavaScript is the most misunderstood language in the world. Some call it broken; others call it beautiful. The truth? It’s both.

console.log(1 + "2"); // "12" (string) console.log(1 + 2 + "3"); // "33" (evaluates left to right: 3 + "3") console.log([] + []); // "" (empty string) console.log([] + {}); // "[object Object]" console.log({} + []); // 0 (Wait, run this in a console... yes, 0) The last one is a parsing edge case where {} is interpreted as an empty code block, not an object. This one angers accountants and mathematicians equally.

const obj = { show }; obj.show(); // obj