Syntax

Arrow Function

const test = () => {
       ...
}

equal

const test = function(){
       ...
}

Rest Param & Spread Syntax (...)

Rest Param

  • accept the numbers of argument as a array

function myFun(a,  b, ...manyMoreArgs) {
  console.log("a", a)
  console.log("b", b)
  console.log("manyMoreArgs", manyMoreArgs)
}

myFun("one", "two", "three", "four", "five", "six")
// Console Output:
// a, one
// b, two
// manyMoreArgs, ["three", "four", "five", "six"]

Spread Syntax

  • Expand array into numbers of argument/ number

  • Expand object into numbers of key-value pair

Destructing

?? vs ||

  • ?? return next item when first item is undefined or null

  • || includes 0 , false , empty string checking

=== vs ==

  • Better to use ===

Last updated

Was this helpful?