rse / es6-features

ECMAScript 6: Feature Overview & Comparison

Home Page: https://rse.github.io/es6-features/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Function-Scoped Functions aren't an ES6 feature

webbedspace opened this issue · comments

commented

Placing a function declaration inside another function declaration has been valid JavaScript since Netscape 2.0, and moreover has never been disallowed by strict mode.

Yes, but not in strict mode since ES5. That's the point here. But I've made it more explicit now. Thanks for the feedback.

commented

I just said:

it has never been disallowed by strict mode.

The only thing strict mode disallowed was block-scoped function declarations. Not function-scoped function declarations.

To summarise:
ALLOWED IN ES5:

"use strict"; function A() { function B() {} }

NOT ALLOWED IN ES5:

"use strict"; { function B() {} }

Ah, understood. You're right, I was wrong here. Now fixed. Thanks for clarification.