Closed
Bug 337540
Opened 19 years ago
Closed 19 years ago
x=setTimeout('...',delay); produces JavaScript errot but no error when x=setTimeout('...',delay);var delay;
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: World, Unassigned)
References
Details
This is sub issue of Bug 332759 Comment #26.
x=setTimeout('...',delay) produces JavaScript errot(delay is not defined), but no error when x=setTimeout('...',delay);var delay;
If "var delay;" is coded after setTimeout call, window.delay is defined before setTimeout call execution.
It's same result as var dealy;x=setTimeout('...',delay); case.
This indicates that "var dealy;" is detected and window.delay is created at compile stage.
I think that existence of window.delay for global variable of "delay" is the reason why JavaScript error is not generated when "x=setTimeout('...',delay);var delay;"
Is this as designed? Defined action by ECMA Script? JavaScript 1.x extention?
Comment 1•19 years ago
|
||
The variable is created when the execution scope is entered, not when the statement is executed. See <http://bclary.com/2004/11/07/#a-12.2>, <http://bclary.com/2004/11/07/#a-10.1.3>.
Reporter | ||
Comment 2•19 years ago
|
||
(In reply to comment #1)
> The variable is created when the execution scope is entered, not when the
> statement is executed.
<http://bclary.com/2004/11/07/#a-10.1.3> clearly says:
> 10.1.3 Variable Instantiation
>(snip)
> * For each VariableDeclaration or VariableDeclarationNoIn in the code,
> create a property of the variable object whose name is the Identifier
> in the VariableDeclaration or VariableDeclarationNoIn, whose value is
> undefined and whose attributes are determined by the type of code.
I knew about FunctionDeclaration but didn't about VariableDeclaration.
Thanks for quick answer. (Forgive my mis-use of Bugzilla for Q&A, please.)
Closing as INVALID.
Status: NEW → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•