mirror of https://github.com/svaarala/duktape.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
578 B
38 lines
578 B
12 years ago
|
/*===
|
||
|
undefined undefined
|
||
|
===*/
|
||
|
|
||
|
/* What should 'var x = x' do?
|
||
|
*
|
||
|
* Because variable declarations are "hoisted", i.e. magically processed
|
||
|
* upon function entry, the right-hand-side 'x' should NOT refer to e.g.
|
||
|
* a global value of 'x', but should be undefined.
|
||
|
*/
|
||
|
|
||
|
var x = 10;
|
||
|
var y = 20;
|
||
|
|
||
|
function f1() {
|
||
|
var x = x;
|
||
|
print(typeof x, x);
|
||
|
}
|
||
|
|
||
|
f1();
|
||
|
|
||
|
/*===
|
||
|
undefined undefined
|
||
|
undefined undefined
|
||
|
===*/
|
||
|
|
||
|
/* Order trick should not help, both should be undefined. */
|
||
|
|
||
|
function f2() {
|
||
|
var y = x;
|
||
|
var x = y;
|
||
|
print(typeof x, x);
|
||
|
print(typeof y, y);
|
||
|
}
|
||
|
|
||
|
f2();
|
||
|
|