I am trying to understand how jQuery is coded.
They have an object:
jQuery.fn = {
//key value pairs
}
But if I type jQuery.fn in the browser console, it just returns [] and not the object itself. Does anyone know why?
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.
jQuery.fnsimply meets the requirements of being array-like for the developer consoles. It’s not actually anArrayinstance*, but it has an interface that affords being treated as an array.*If
jQuery.fnwere actually an array,jQuery.fn instanceof Arraywould evaluate totrue; it doesn’t. It does copy some of theArray.prototypemethods though.If you want to check if an object is actually an
Array, there are two means, the simplest isobj instanceof Array, however this will be true for objects that inherit fromArray. If you want to check that an object is an Array, but need to exclude objects that inherit fromArrayyou should use:Example: