What are the advantages of ES6 compared to ES5 when it comes to block scope functions? Although the blocks may look similar in both cases, what impact does it have performance-wise and which approach is more efficient?
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;
})();