What advantages does ES6 has over ES5, regarding block scope functions? I mean the block looks quite similar in both the cases so what difference it makes, performance wise which approach is better to use?
ES6 Block
{
function foo() {
return 1;
}
foo() === 1;
{
function foo() {
return 2;
}
foo() === 2;
}
foo() === 1;
}
ES5 Block
(function () {
var foo = function () {
return 1;
}
foo() === 1;
(function () {
var foo = function () {
return 2;
}
foo() === 2;
})();
foo() === 1;
})();