As suggested in the code comments, this section should accurately supplement the first steps described in the specification .
- Let O be TOObject (this value).
- ReturnIfAbrupt (O).
Despite the fact that it is a little out of order, it does fucntion ToObject(this value) :
var O = Object(this);
Basically, if it is called for a non-object, the non-object should be dropped in Object .
For example, if we were to run this bit of mostly meaningless code in the JavaScript engine that supports this method, we will see that an instance of the Number object is returned.
Array.prototype.fill.call(123);
This line will provide the same result from the polyfill.
source share