Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_.bindAll doesn't bind prototype functions #243

Closed
gavacho opened this issue Jul 12, 2011 · 1 comment
Closed

_.bindAll doesn't bind prototype functions #243

gavacho opened this issue Jul 12, 2011 · 1 comment

Comments

@gavacho
Copy link

gavacho commented Jul 12, 2011

Example:

var MyExample = function() {};
MyExample.prototype.exampleValue = true;
MyExample.prototype.getExampleValuePrototype = function() { return this.exampleValue; }

var myInstance = new MyExample();
myInstance.getExampleValue = function() { return this.exampleValue; }

alert(myInstance.getExampleValue.apply({}));
alert(myInstance.getExampleValuePrototype.apply({}));
// result: both alert 'undefined'

_.bindAll(myInstance);
alert(myInstance.getExampleValue.apply({}));
alert(myInstance.getExampleValuePrototype.apply({}));
// result: getExampleValue alerts 'true', getExampleValuePrototype alerts 'undefined'

_.bindAll(myInstance, 'getExampleValuePrototype');
alert(myInstance.getExampleValue.apply({}));
alert(myInstance.getExampleValuePrototype.apply({}));
// result: both alert 'true'
jashkenas added a commit that referenced this issue Jul 13, 2011
@jashkenas
Copy link
Owner

Thanks. Patched in the above commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants