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.
function outer() let secret = 'closed over'; return function inner() console.log(secret); ; understanding javascript the weird part parts
typeof null; // 'object' (bug in JS) typeof function(){}; // 'function' (but not a separate type) [] instanceof Array; // true [] instanceof Object; // true (arrays are objects) false , 0 , '' (empty string), null , undefined , NaN , -0 , 0n Here’s a structured guide to understanding the classic
Everything else is truthy (including [] , {} , "0" ). The weird part: == does type coercion. The weird part: == does type coercion
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.
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.
function outer() let secret = 'closed over'; return function inner() console.log(secret); ;
typeof null; // 'object' (bug in JS) typeof function(){}; // 'function' (but not a separate type) [] instanceof Array; // true [] instanceof Object; // true (arrays are objects) false , 0 , '' (empty string), null , undefined , NaN , -0 , 0n
Everything else is truthy (including [] , {} , "0" ). The weird part: == does type coercion.
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.