Closed claudepache closed 4 years ago
Preliminary tests on Firefox, Chrome, Safari and Edge:
caller
or arguments
on:
caller
is about to return:
Note: When testing Safari, we should be aware that, because of PTC, the caller may not be the one that you think:
function getCaller() { return getCaller.caller }
;(function() { "use strict"; var r = getCaller(); return r })()
// TypeError: Function.caller used to retrieve strict caller
;(function() { "use strict"; return getCaller() })()
// PTC applies; no error (unless executed from within a strict-mode environment, of course)
So, roughly, for case 1, we can distinguish two classes of functions:
.arguments
or .caller
property on those functions is allowed;.arguments
or .caller
on those functions throws a TypeError.Edge treats methods and getters in object literals as “ES3 functions”, other engines as “other functions”.
And for case 2, we can distinguish three or four classes of functions:
.caller
is allowed;.caller
is forbidden: either throw a TypeErrror or return null;
.caller
is either forbidden (returning null); or allowed (which is objectionable).
Current implementations may or may not add restrictions on the following kinds of (mostly post-ES3) function:
Moreover, there are two kinds of restriction that may apply:
caller
or thearguments
property on such a function object:caller
property is about to return such a function object: