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.
| 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 | understanding javascript the weird part parts
function getObj() return // ASI adds semicolon here → returns undefined ok: true ; 0 == false // true '' == false
function Dog(name) this.name = name; Dog.prototype.bark = function() return 'woof'; ; const d = new Dog('Rex'); d.bark(); // 'woof' Weird parts: | Binding Rule | Example | this value