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

Just a question #2

Closed
xiaoyuzhzh opened this issue Feb 9, 2015 · 2 comments
Closed

Just a question #2

xiaoyuzhzh opened this issue Feb 9, 2015 · 2 comments
Labels

Comments

@xiaoyuzhzh
Copy link

Your blog is awesome!!!!
But I was confused with this.
In the function decorate ,you wrote this
'return oldFunc.apply(that, Array.prototype.slice.call(arguments));'.
Why you 'apply(null.....', this will make functions of the object lose ' this ' in their context. Why didn't you give obj to them.

@Jacob-Friesen
Copy link
Owner

Hello, sorry about the late reply, for some reason Github did not give me an email about this. Anyways, I am assuming you are referring to the 2014 decorate.js post. I think I just forgot to add context passing at that time as it was not essential for the example. This is also combined with my style of coding which generally avoids using 'this'. I find it much clearer and less error prone when a context is explicitly passed in to a function as an argument or comes from a context created directly in the main part of an object.

Though for this example passing in obj would probably be clearer, so I have added that. Thanks for pointing that out.

@xiaoyuzhzh
Copy link
Author

Got it. Thank u.

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

No branches or pull requests

2 participants