Devloped by Brendan Eich in 1995
Appeared on Netscape Navigator 2.0
Submitted to ECMA in 1996
ActionScript and JScript has derrived from this
ES4 2007
ES5 2009
ES6 2013
babel
Its a transpiler which converts es6 to es5
through example
const pi = '3.14'; pi = 3.14159265359 //error you can not change the value of constant
Enables block scoping
(function(flag){ if(flag){ let x = 10 console.log(x) //x is 10 } console.log(x) // x is undefined })
class Vehicle { constructor (name, type) { this.name = name; this.type = type; } getName () { return this.name; } getType () { return this.type; } } class Car extends Vehicle { constructor (name) { super(name, 'car'); } getName () { return 'It is a car: ' + super.getName(); } } let car = new Car('Tesla'); console.log(car.getName()); // It is a car: Tesla console.log(car.getType()); // car
lets forget for(i ; i < blah ; i ++)
var planets = ['Mercury', 'Venus', 'Earth', 'Mars']; planets.forEach(function(planet){ console.log(planet) }) //or for(var planet in planets){ console.log(planet) }
Writing functions
function myFunction(){ console.log("hello wolrd!") } () => { console.log("Hello world!") } var myFunction = function(){ console.log("Hello world!") } var myFunction = () => { console.log("Hello world") }
function sum(a, b){ return a+b; } var sum = (a,b) => { return a+b } var sum = (a, b) => a+b //automatically implies return
Enables block scoping
class Car { constructor (name) { this._name = name; } set name (name) { this._name = name; } get name () { return this._name; } } let car = new Car('Tesla'); console.log(car.name); // Tesla car.name = 'BMW'; console.log(car.name); // BMW
Default function parameter
collections
maps , its a kind of key value pair storing
modules, export and import