I'm reading The ES6 & Beyond book, Chapter 2: Syntax for the You Don't Know JS series. He mentions how functions are block scoped in ES6, and gives this example, that I altered.
I changed the name to fooBlock and had it print something out to the console. So I expected the first calling of fooBlock to work, and the second calling of it to give an error...but instead it was able to call the function outside the block scope.
What am I not getting?
{
fooBlock(); //prints "Here is fooBlock"
function fooBlock(){
console.log("Here is fooBlock");
}
}
fooBlock(); //prints "Here is fooBlock" when I expected an error