Methods Flashcards
Imports a library as an object
node require(library)
ie let obj = require(‘readline-sync’)
destructive, pushes a new element to the end of an array.
Array.push()
non-destructive, returns a brand new array that contains all the elements from the original array followed by all of the arguments passed to it:
Array.concat()
destructive, changes the contents of an array by removing or replacing existing elements and/or adding new elementsin place
Array.splice(start, deleteCount)
non-destructive, creates a new array populated with the results of calling a provided function on every element in the calling array.
Array.map()
non-destructive, returns a new array that includes all elements from the calling array for which the callback returns a truthy value.
Array.filter()
non-destructive, reduces the contents of an array to a single value.
Array.reduce()
reducetakes two arguments: a callback function and a value that initializes something called theaccumulator.
non-destructive
determines whether an array includes a given element
Array.includes()
non-destructive, searches an array for an element with a given value and returns the index of the found element. If the element is not found,returns-1.
Array.indexOf()
destructive, rearranges the elements of an array in sequence. It returns a sorted array.
Array.sort()
non-destructive, extracts and returns a copied portion of the array. It takes two optional arguments. The first is the index at which extraction begins, while the second is where extraction ends (non inclusive of the last index)
Array.slice()
destructive, reverses the order of an array.
Array.reverse()
This static method returns an object’s keys as an array. You can iterate over that array using any technique that works for arrays.
Object.keys()
returns the object’s own keys: it does not include any keys from the prototype objects.
This static method extracts the values from every own property in an object to an array:
Object.values()
This static method returns an array of nested arrays. Each nested array has two elements: one of the object’s keys and its corresponding value:
Object.entries()