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.
36 lines
696 B
36 lines
696 B
/*===
|
|
321
|
|
undefined
|
|
===*/
|
|
|
|
/* If an eval() call happens in a strict function, the eval code will be
|
|
* considered strict even without an explicit strict declaration.
|
|
*
|
|
* A strict direct eval call gets a fresh variable environment so any
|
|
* declarations will not be visible to the caller's env.
|
|
*/
|
|
|
|
function nonstrict_parent() {
|
|
eval('var x = 321'); // new declaration, goes to parent
|
|
print(x);
|
|
}
|
|
|
|
function strict_parent() {
|
|
'use strict';
|
|
|
|
eval('var x = 321'); // new declaration, goes to fresh env
|
|
print(typeof x); // -> undefined
|
|
}
|
|
|
|
try {
|
|
nonstrict_parent();
|
|
} catch (e) {
|
|
print(e.name);
|
|
}
|
|
|
|
try {
|
|
strict_parent();
|
|
} catch (e) {
|
|
print(e.name);
|
|
}
|
|
|
|
|