jQuery is a Javascript library and framework, but when we are programming with jQuery into DOM problems/solutions, we can practice a style quite different of programming... We can read about jQuery at Wikipedia,
The set of jQuery core features — DOM element selections, traversal and manipulation —, enabled by its selector engine (...), created a new "programming style", fusing algorithms and DOM-data-structures
This question is similar to the "subquestion-3" of this question but not so generic. The focus here is about this new kind of "programming style"... So, the question:
Is the "jQuery programming style in DOM context" a new paradign? Or it is more one example of reactive programming (not "cell-oriented" but "DOM-node oriented") or another one?
We have no "standard taxonomy of paradigms", so, please, in your answer, indicate also your "best choice for Wikipedia Paradign".
Example: if you understand that "jQuery programming DOM" is like "awk filtering data", your choice can be event-driven.
1 Answer 1
If there is a paradigm in use in jQuery, it is functional programming, with some Fluent Interface sprinkled in for good measure. It is the fluent interface pattern that provides for the method chaining capability.
Beyond that, it's simply clever and deliberate application of an API. Under the hood, there's a lot of jiggery going on to insure cross-browser compatibility, but the foundational ideas behind jQuery are relatively simple. Just goes to show you how useful a well-designed API can be.
-
See @OnesimusUnbound comments: "chained methods" are pipelines... And I undertand "fluent interface" as "chain method" synonymous, is not it? About jQuery, the focus of the question is only "jQuery working with DOM", where a selectors are used.Peter Krauss– Peter Krauss2013年07月02日 18:47:26 +00:00Commented Jul 2, 2013 at 18:47
-
1How is jQuery "functional"? The selector parts of it might be, but most methods do mutate state in a very unfunctional way.Bergi– Bergi2014年03月22日 16:23:00 +00:00Commented Mar 22, 2014 at 16:23
Explore related questions
See similar questions with these tags.
jQuery selectors are like XSLT template selectors
to be precise, they're CSS Selector + JQuery-specific. Anyway, I agree chained method simulates UNIX piping. My point is that JQuery used existing paradigms to create an elegant way to deal with DOM.