Which is best practice, which results in better performance?
using closure or dojo.lang.hitch ?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Actually
lang.hitch(scope, method)returns a closure, i.e. it returns a function, which will call functionmethodin the givenscope. That’s useful especially when defining callbacks in object oriented code, so you can write:instead of:
Something like this will work:
but
thisinside thecallbackmethod will point to thebutton.See the complete code with additional details in jsFiddle: http://jsfiddle.net/phusick/r7jLr/