js basics Flashcards
slice
Returns a shallow copy of a portion of an array from start to end (the end is not included)
[].slice(start, end);
splice
method changes the contents of an array by removing or replacing existing elements and/or adding new elements in place
[].splice(start, deleteCount, item1, item2, itemN)
concat
this method is used to merge two or more arrays. This method does not change the existing arrays, but instead returns a new array
array1.concat(array2);
reduce
it runs a callback function on each element of the array, in order, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the array is a single value
array1.reduce((previousValue, currentValue) => previousValue+currentValue, initialValue);
filter
creates a new array of all elements that pass the qualifying function argument
[].filter(x => x.length > 6);
map
creates a new array of the elements created by calling the provided function on each element of an array
[].map(x => x * 2);
what does .?? do
a logical operator that returns its right-hand side operand when its left-hand side operand is null or undefined, and otherwise returns its left-hand side operand
what is this called .??
Nullish coalescing operator
what does .? do?
enables you to read the value of a property located deep within a chain of connected objects without having to check that each reference in the chain is valid
get
used to get a resource from a server
If you perform a GET
request, the server looks for the data you requested and sends it back to you. In other words, a GET
request performs a READ
operation.
post
used to create a new resource on a server
If you perform a POST
request, the server creates a new entry in the database and tells you whether the creation is successful. In other words, a POST
request performs an CREATE
operation.
what is .?
a optional chaining operator
PUT
used to update a resource on a server. If you perform a PUT
or PATCH
request, the server updates an entry in the database and tells you whether the update is successful
PATCH
used to update a resource on a server. If you perform a PUT
or PATCH
request, the server updates an entry in the database and tells you whether the update is successful
DELETE
used to delete a resource from a server. If you perform a DELETE
request, the server deletes an entry in the database and tells you whether the deletion is successful
shift
remove from the begining of an array
push
add an item to the end of the array and returns that element
pop
remove the last item from an array and returns that element