Understanding Javascript The Weird Part Parts _best_ -

0 == false // true '' == false // true null == undefined // true [] == '' // true (both become empty string) [] == 0 // true Always prefer === (no coercion), except when checking null == undefined . 7. Asynchronous Weirdness: Event Loop The weird part: JS is single-threaded but can handle async tasks.

function getObj() return // ASI adds semicolon here → returns undefined ok: true ; understanding javascript the weird part parts

Everything else is truthy (including [] , {} , "0" ). The weird part: == does type coercion. 0 == false // true '' == false

| Binding Rule | Example | this value | |-------------------|----------------------------------|----------------------------| | Default | fn() | window (strict: undefined ) | | Implicit (object) | obj.fn() | obj | | Explicit | fn.call(obj) , fn.apply(obj) | obj | | new binding | new Fn() | new instance | function getObj() return // ASI adds semicolon here

'5' - 1; // 4 (string to number) '5' + 1; // '51' (number to string) +'5'; // 5 (unary plus) !!'false'; // true (non-empty string) use Number() , String() , or explicit Boolean() . 9. Semicolon Insertion (ASI) Weird part: JS adds semicolons automatically, sometimes breaking code.