Saqib Razzaq (SakyTalks)

JavaScript ES6+ Notes

JavaScript ES6 Notes

Def vars const = cannot redeclare, cannot changed value let = can change value, cannot redeclare

let + const = if inside { } then it won't work outside

Concatination

Object Literals If you want to return an object you don't need to do following

function getBook(name, author) {
  return {
    name: name,
    author: author
  }
}

If variable names are the same as the value you want to return, just use the variable instead like so

function getBook(name, author) {
  return {
    name,
    author
  }
}

**Object deconstruction*** Instead of list.item you can select multiple items

  name: "Shopping list",
  items: ['cow', 'milk'],
  car: xli
}

const {name, car} = list;

^ That will give me both the values

Arrow functions

const mylocation = (location) => {
  console.log(`My location is ${location}`)
}

defalut parameters You can set values like php in func params

New array functions

#javascript