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.
28 lines
454 B
28 lines
454 B
/*
|
|
* Native functions can act as setters and getters.
|
|
*/
|
|
|
|
/*===
|
|
val is a number
|
|
===*/
|
|
|
|
function test() {
|
|
var obj = {};
|
|
Object.defineProperty(obj, 'prop', {
|
|
get: Math.random,
|
|
set: function() { throw Error('setter'); }
|
|
});
|
|
|
|
var val = obj.prop;
|
|
if (typeof val === 'number') {
|
|
print('val is a number');
|
|
} else {
|
|
print('val is not a number');
|
|
}
|
|
}
|
|
|
|
try {
|
|
test();
|
|
} catch (e) {
|
|
print(e);
|
|
}
|
|
|