Cart 0

Javascript Weird Parts ~repack~ File

Put { on the same line as return . 6. this – The Shape-Shifter In most languages, this is predictable. In JavaScript, it depends on how you call the function.

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.

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 :

These quirks are frustrating until you understand why they exist. Once you do, you stop fighting the language and start leveraging it.