Monday, February 27, 2017

Modules & Classes in ES6

Modules:
Module help us with encapsulation by exposing from a given file the pieces we want to be access publically. An export statement will be used for that.

export {
     show: someFunc()
}


Then an import statement is used to import that piece:

import { show } from './my-file.js'

Sunday, February 19, 2017

ES6 Features

New features in ES6 are:

  • let, const and Block Scoping,
  • Arrow Functions =>,
  • Default Function Parameters,
  • Rest and Spread,
  • Object Literal Extensions,
  • for…of Loops,
  • Octal and Binary Literals,
  • Template Literals
  • Destructuring

let, const and Block Scoping:

let

let statement allows to declare variables that are limited in scope to the block, statement or expression on which it is used.

Arrow Functions =>

Arrow functions are anonymous functions with shorter syntax than a function.

Arrow function without any arguments.

var geEmployee = () => console.log(‘Employee Name’);

Default Function Parameters:

var getEmployee = function(id = 101){
     console.log(id)
};
getEmployee();

Thanks,
Bimal