What is extended mode?
dmpRandomblue提出了一个问题：What is extended mode?，或许与您遇到的问题类似。
It looks like “extended mode” was removed from the current development version of the harmony spec on February 27, 2012, but there’s a description of what it was supposed to be in a few older ones (this one is from January 16, 2012):
10.1.2 Extended Code
Extended code is any code contained in an ECMAScript Program syntactic unit that contains occurrences of lexical or syntactic productions defined subsequent to the Fifth Edition of the ECMAScript specification. Code is interpreted as extended code in the following situations:
- Global code is extended global code if it is contained in an ECMAScript Program syntactic unit that has been designated as an extended Program unit in an implementation defined manner or if ???.
- Eval code is extended eval code if the call to eval is a direct call (see 126.96.36.199.1) to the eval function that is contained in extended mode code or if it begins with ???.
- Function code that is part of a FunctionDeclaration, FunctionExpression, or accessor PropertyAssignment is extended function code if its FunctionDeclaration, FunctionExpression, or PropertyAssignment is contained in extended mode code or if the function code begins with ???.
- Function code that is supplied as the last argument to the built-in Function constructor is strict function code if the last argument is a String that when processed as a FunctionBody begins with ???.
The term “strict code” is used to designate both actual strict mode code and extended code while the term “extended code” only designates actual extended code. The term “base code” is used to designate code that is not extended code.
As for the connection with strict mode, that seems to be specific to V8’s (experimental) implementation. Here’s what the changelog for revision 10062, which introduced the
--harmony flag, says:
This CL introduces a third mode next to the non-strict (henceforth called ‘classic mode’) and ‘strict mode’ which is called ‘extended mode’ as in the current ES.next specification drafts. The extended mode is based on the ‘strict mode’ and adds new functionality to it. This means that most of the semantics of these two modes coincide.
The ‘extended mode’ is entered instead of the ‘strict mode’ during parsing when using the ‘strict mode’ directive “use strict” and when the the harmony-scoping flag is active. This should be changed once it is fully specified how the ‘extended mode’ is entered.