es6

ES6

View the Project on GitHub

Core ES6 features

From var to const/let

Declaring a variable with var that means variable can be accessed anywhere within the function. In turn variable with var keyword is function scope.

var

var x = 3;
function f(random){
if(random){
	var x = Math.random(); 
	return x;
}
return x;
}
f(false); // undefined

What is going here? Why you got undefined in the above code. This is how it breaks down

var x = 3;
function f(random){
var x;
if(random){
	x = Math.random();
	return x;
}
return x;
}
f(false); // undefined

let

let y = 3;
function f(random){
if(random){
	let y = Math.random();
	return y;
}
return y;
}
f(false) // 3

Summary

ToDO

Add more examples