I'd like to know why the error is not raised inside the catch block when i use Object.defineProperty()
method with get()
and set()
?
try {
var f;
Object.defineProperty(window, 'a', {
get: function() {
return fxxxxx; // here: undef var but no error catched
},
set: function(v) {
f = v;
}
});
} catch (e) {
console.log('try...catch OK: ', e);
}
a = function() {
return true;
}
window.a();
// Expected output: "try...catch OK: ReferenceError: fxxxxx is not defined"
// Console output: "ReferenceError: fxxxxx is not defined"