JS Syntax
  • Introduction
  • this
  • block-level scope
  • ===
  • inefficient DOM manipulation
  • Reference equality, shallow equality and deep equality
  • D3 - 2
  • D3 - 5
  • D3 - static
Powered by GitBook
On this page

Was this helpful?

===

// All of these evaluate to 'true'!
// type coercion automatically
console.log(false == '0');
console.log(null == undefined);
console.log(" \t\r\n" == 0);
console.log('' == 0);

// And these do too!
if ({}) // ...
if ([]) // ...
  • Both {} and [] are objects, and any object will be coerced to a boolean value of true in JavaScript.

  • Prefer to use === and !== to avoid any unintended side-effects of type coercion.

NaN

console.log(NaN == NaN);    // false
console.log(NaN === NaN);   // false
console.log(isNaN(NaN));    // true
Previousblock-level scopeNextinefficient DOM manipulation

Last updated 5 years ago

Was this helpful?