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

On the distinction between jQuery core methods ( .each() ) in the $.fn name space and jQuery utility methods ( $.each() ) not in the $.fn name space #799

Open
ghost opened this issue Apr 29, 2021 · 0 comments

Comments

@ghost
Copy link

ghost commented Apr 29, 2021

The Using jQuery Core chapter begins with the section titled $ vs $().

It's my thought that some additional wording could make the section's lessons more easily realized.

That section draws the distinction between jQuery core (object) methods called on jQuery selections and jQuery utility methods not called on selections. Thrown in on top of that is the further distinction between the $.fn namespace and the $ namespace.

Core (object) methods are identified simply by their names ( .each() ) but are in the $.fn namespace.

Utility methods ( $.each() ) are explicitly identified as members of the jQuery namespace, $, and are not in the $.fn namespace.

Get it?

.each() in $.fn namespace.
$.each() not in $.fn namespace.

My point is that that distinction is not so clearly made in the article. It took me several readings and a day's rumination before the fog lifted. I think that the jQuery novice, who is after all the section's target, would be better served by a more explicit and specific drawing of the distinction than is currently the case.

The point might also be explicitly made that core methods (.remove()) are also called object methods because they have an object, i.e., the jQuery selection ( $( "h1" ) ) upon which they are called ( $( "h1" ).remove() ). I think that would make the terminology seem more sensible and less arbitrary.

May I also suggest that this would be the place to give some insight into the namespace concept, just a paragraph or two. If not, then at least a citation to an article explaining the concept.

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

No branches or pull requests

1 participant