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.
35 lines
479 B
35 lines
479 B
11 years ago
|
/*
|
||
|
* Use eval() indirectly with call() or apply().
|
||
|
*/
|
||
|
|
||
|
/*===
|
||
|
apply
|
||
|
hello from eval!
|
||
|
call
|
||
|
hello from eval!
|
||
|
bind
|
||
|
hello from eval!
|
||
|
===*/
|
||
|
|
||
|
function test() {
|
||
|
var code = 'print("hello from eval!");';
|
||
|
var f;
|
||
|
|
||
|
print('apply');
|
||
|
eval.apply(this, [ code ]);
|
||
|
|
||
|
print('call');
|
||
|
eval.call(this, code);
|
||
|
|
||
|
/* Also test indirect use of eval through bind() */
|
||
|
print('bind');
|
||
|
f = eval.bind(this, code);
|
||
|
f();
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
test();
|
||
|
} catch (e) {
|
||
|
print(e);
|
||
|
}
|