-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript
kitiya edited this page Mar 7, 2020
·
4 revisions
//TODO
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]const fiveUp = nums.filter(num => num >= 5); // [5, 6, 7, 8, 9]Syntax reduce(function, initialValue)
const initialValue = 0;
const total = nums.reduce((accumulator, num) => {return accumulator + num;}, initialValue); // 55//TODO
// TODO
// TODO
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