Skip to content

JavaScript

kitiya edited this page Mar 7, 2020 · 4 revisions

//TODO

map()

const nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const double = nums.map(num => num * 2); // [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

filter()

const fiveUp = nums.filter(num => num >= 5); // [5, 6, 7, 8, 9]

reduce()

Syntax reduce(function, initialValue)

const initialValue = 0;
const total = nums.reduce((accumulator, num) => {return accumulator + num;}, initialValue); // 55

Other Resources

//TODO

// TODO

Pass by value vs pass by reference

// TODO

JavaScript Flasy

There are 7 falsy values in JavaScript.

  • false:
  • 0: the number zero
  • 0n: BigInt
  • "", '', ````: an empty string
  • null: the absence of any value
  • undefined: undefined - the primitive value
  • NaN: not a number

Type Coercion

Clone this wiki locally