I was reading ECMA 5 262, and feel confused on the term “strict reference” in http://es5.github.com/#IsStrictReference:
A Reference is a resolved name binding. A Reference consists of three components, the base value, the referenced name and the Boolean valued strict reference flag. The base value is either undefined, an Object, a Boolean, a String, a Number, or an environment record (10.2.1). A base value of undefined indicates that the reference could not be resolved to a binding. The referenced name is a String.
There’s not much description on it. The only related operation on Reference is
IsStrictReference(V). Returns the strict reference component of the reference V.
but no operation to set, neither description how we can decide the value.
I guess it must be related to the strict mode, but how can i tell what’s the value for a specific Reference?
As far as I understand, it’s a property for references set to true when using references with
strict modein ECMAScript 5 (aka ES5) initialized. Whenstrict modeis set, more operations will lead to errors (syntax, reference, for example initializing a variable without thevarkeyword). See the MDN-documentation for more onstrict mode.[edit] based on comment
I think it’s for the scope where
strict modeis defined. So inExecuting
strict()throws aReferenceError, butnonstrict()doesn’t. If you had placed theuse strict-statement outside the function blocks, executing both functions would throw aReferenceError.