Editing JavaScript/Notes/Scope
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 138: | Line 138: | ||
</source> | </source> | ||
The Mozilla docs on Reference error simply state: | |||
<blockquote> | |||
A ReferenceError is thrown when trying to dereference a variable that | |||
has not been declared. | |||
</blockquote> | |||
I realize accessing a non existent property on an object should return | |||
undefined... which accounts for the first two cases... but whats going | undefined... which accounts for the first two cases... but whats going | ||
on in the third case? | on in the third case? | ||
</blockquote> | </blockquote> | ||
the ECMAScript specification | The MDN docs are inadequate. Instead, search the ECMAScript specification for | ||
<code>[http://www.ecma-international.org/ecma-262/5.1/#sec-15.11.6.3 ReferenceError]</code> | <code>[http://www.ecma-international.org/ecma-262/5.1/#sec-15.11.6.3 ReferenceError]</code>. | ||
This shows that <code>ReferenceError</code> is thrown in strict mode when making an assignment | |||
to an undeclared identifer. | |||
<source lang="javascript"> | <source lang="javascript"> | ||
Line 151: | Line 158: | ||
</source> | </source> | ||
Referring to the example, getting a property off an object, the prototype chain is | |||
searched. When that happens, if the property is not found, then | searched. When that happens, if the property is not found, then | ||
<code>undefined</code> results. | <code>undefined</code> results. |