Function.prototype.name getter brokes function name getter #454
Closed
Description
This code breaks Function.prototype.name
in 100% of cases
var funcNameBeforeProtoCall = (function bar() {}).name
var funcNameBeforeProtoCallEquals = funcNameBeforeProtoCall === 'bar';
debugger;
Function.prototype.name;
var funcNameAfterProtoCall = (function foo() {}).name
var funcNameAfterProtoCallEquals = funcNameAfterProtoCall === 'foo';
debugger
launchable code: https://codepen.io/ColCh/pen/Oqpqqp
Try it in IE 11 and this would be resulted in this:
WHY ?!
Because this code is executed against this
variable of Function.prototype
Lines 158 to 159 in 271142c
and this code assigns getter with for Function.prototype
name
property with null
value.
Lines 160 to 165 in 271142c
Solution: skip defineProperty
for null
names
Metadata
Assignees
Labels
No labels