# ๐Ÿ“” ES6 EcmaScript 6

2 min read, 288 words es6scriptes2015ecmascript2015
var counter = 10
// ... some code
var counter = 5
  • Variables declared outside function could be used inside functions.
  • However functions declared inside fucntion could not be used outside

# String Concatination

// older syntax
console.log('value = ' + value);

// newer syntax - template delimeters
console.log(`value = ${value}`);

# Object Deconstruction

# Arrow Function

that = this non-sense

  • Arrow function preserves the references
  • If you use normal function() {..}, references to this are not preserved
  • Declare default parametrs with in the arrow function
const user ={
  name: 'Ed',
  age: 25,
  sayName: function() {
    console.log(`My name is ${this.name}`);
    const fullName = () => {
      console.log(`name is ${this.name} and age is ${this.age}`);
    };
    fullName();
  }
}

// practical scenario
button.addEventListner('click', fucntion() {
  this // means button
})

Iterating over List/ Arrays

someList.foreach((item, index) => {
  console.log(`Item = ${item} at index ${index}`);
})
  • Use map() to transform each element in array inplace

# Array Filters

  • get only a particular item from list

# Constructor and Classes

  • generally starts with caps letter
  • new creates a copy
  • How to add properties and methods to classes?
  • ClassName.Prototype.methoName = function() { ... }
  • call()
  • class inheritance extends

# Callbacks vs Promises

  1. Variables
  2. String Concatenation
  3. Object Literals
  4. Object Deconstruction
  5. Arrow Functions
  6. Default Parameters
  7. Array Functions
  8. Constructor Functions and Classes
  9. Promise
    1. .then
    2. .catch

# ๐Ÿ“Ž References

Subscribe to our Newsletter

If you like my work and think it was helpful kindly support my work


Buy Me A Coffee