DEV Community

acuevasd
acuevasd

Posted on • Updated on

Scrimba's JavaScript Deep Dive - Part III

Functions:

  • define by functionas key word
  • a function will return undefinedby default
  • closure: how to remember values (or pass down)
  • toFixed: return string, so we need to update the type
  • we can also use default values (with equal in the declaration of arguments)
  • we need to write functions think that arguments will not be correctly given
  • arrow function don't need function key word, just =>. But by default they use implicit return (so we don't need the key word)
  • higher order function: call an function in a function (all callbacks are higher order)
  • arrow function need a variable storage the function
  • functions can be thought like actions, so better to name them as verbs. Be explicit (it don't need to be short), but be consistent with the names you use (simple prefix are great!)

Object and Maps:

  • We can create objects to organize, with keys (references)
  • key don't need "
  • to use them object.key
  • object are great for static information
  • object are collection of primitive (6 types: undefined, null, boolean, number, string, and symbol)
  • object are not the equally to other (exactly the same)
  • object are passed as reference (not a copy), so if we are not careful, we can update both objects at once
  • dot notation is the most comfortable way to reach values
  • we can destructured objects properties and make them into variables of the same name using { }
  • Object.assign({}, obj1,obj2) we should make a new object, to merge to previous objects. Or ...obj to spread. For both, order matters, the last is the one that will be use.
  • Maps: when key is not a string or symbol

Top comments (0)