puma
puma copied to clipboard
Function.prototype.bind() method fails
Using the Function.prototype.bind() method [http://www.ecma-international.org/ecma-262/5.1/#sec-15.3.4.5] makes the process fail or doesn't return the object correctly. E.g.:
var scope = 'global';
var order = { scope: 'THIS', getScope: Function('return this.scope;') };
var unbound_scope = order.getScope;
var order_scope = unbound_scope.bind(order);
order_scope();
or
this.x = 9;
var module = {
x: 81,
getX: function() { return this.x; }
};
var retrieveX = module.getX;
var boundGetX = retrieveX.bind(module);
boundGetX();
Have you got some error description? Regardless I'll check it.
First example fails without throwing error. As for expected return in second example (which doesn't seem to fail) we should read the linked ECMA section thoroughly and check it.
I'm working on it