Uncut Daily

JavaScript Methods Cheat Sheet

Map
Returns: a new array, actual Boolean values

let people = ["mike", "john", "sam", "joe"];

let array = people.map((person) => person.length > 3);

Output: [true, true, false, false]

Array Methods That Mutate Original Array

There are 9 methods that mutate an array.

splice()

reverse()

sort()

fill()

pop(), push(), shift(), unshift()

copyWithin()

Strings on the other hand are immutable, no method changes original string. All 6 Primitive values (stringnumberbigintbooleanundefined, and symbol) in JavaScript are immutable.

Leave a Reply

Your email address will not be published. Required fields are marked *