Skip to main content

Weird Part Parts Best: Understanding Javascript The

Here’s a structured guide to understanding the classic (and famously quirky) areas of JavaScript—often referred to as the “weird parts” made popular by Anthony Alicea’s course “JavaScript: Understanding the Weird Parts” . The weird part: You can use variables before they’re declared.

Everything else is truthy (including [] , {} , "0" ). The weird part: == does type coercion. understanding javascript the weird part parts

function Dog(name) this.name = name; Dog.prototype.bark = function() return 'woof'; ; const d = new Dog('Rex'); d.bark(); // 'woof' Weird parts: Here’s a structured guide to understanding the classic

getObj(); // undefined Place { on same line as return . 10. NaN – Not a Number Weird part: NaN is a number type, and it’s not equal to itself. The weird part: == does type coercion

| 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 |