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.
40 lines
897 B
40 lines
897 B
/*
|
|
* The 'typeof' operator requires that an 'undefined' value is returned
|
|
* if 'typeof' is applied to an unresolvable reference (E5 Section 11.4.3).
|
|
* Usually unresolvable references cause a ReferenceError.
|
|
*
|
|
* This requires special handling in the compiler, which emits, in the worst
|
|
* case, an TYPEOFID opcode for handling this run-time. Any compile-time
|
|
* resolvable references (concretely: register bound identifiers which are
|
|
* always non-deletable) don't require this special handling.
|
|
*
|
|
*/
|
|
|
|
/*===
|
|
undefined
|
|
undefined
|
|
===*/
|
|
|
|
try {
|
|
print(typeof foo); // unresolvable -> undefined; requires TYPEOFID
|
|
} catch (e) {
|
|
print(e.name);
|
|
}
|
|
|
|
try {
|
|
print(typeof ((foo))); // parens must have no effect
|
|
} catch (e) {
|
|
print(e.name);
|
|
}
|
|
|
|
/*===
|
|
number
|
|
===*/
|
|
|
|
function func(x) {
|
|
// register-bound variables are always resolvable
|
|
return typeof x;
|
|
}
|
|
|
|
print(func(3));
|
|
|
|
|