/hyf-js-week-5

Repo for teaching Hack Your Future Javascript 5th week.

Primary LanguageJavaScript

HYF - JS WEEK 5

INSTALLATION

  • Install dependencies yarn install
  • Create server/db.json file with this contents:
{
  "people" : []
}
  • Start server yarn start

JSON

  • JSON.stringify()
  • JSON.parse()

Functions

  • Simple functions
  • Arrow functions

Local storage

  • localStorage.getItem(name)
  • localStorage.setItem(name, value)

Arrays and manipulation

Adding items

  • .push() --> Add item to end of array

  • .unshift() --> Add item to beginning of array

Removing items

  • .shift() --> Remove first element from array

  • .pop() --> Remove last element from array

  • .splice() --> Remove a specific element from array using index

Useful iterators over arrays

  • .map() --> Creates a new array with the results of calling a provided function on every element in the calling array.

  • .filter() --> Creates a new array with all elements that pass the test implemented by the provided function.

  • .sort() --> Sorts the elements of an array in place and returns the array.

  • .reduce --> Applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value**.