I want to know the differences between:
$('a').map(function(){return this})
$.map($('a'), function(){return this})
They behave differently when I test them in firebug console.
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.
Having just briefly tested, they do perform differently. ‘this’ in the context of the latter references the window object. However you do have access the current element when looping through the object/array passed in:
The latter is typically used for non-jQuery objects and arrays, whereas the former is for this purpose.
See the documentation for more information:
http://api.jquery.com/map/
http://api.jquery.com/jQuery.map/