modern-web-design-and-development

(Brent) #1
2 var obj2 = {three: 'trois', four: 'quatre', some_others: {five:
'cinq', six: 'six', seven: 'sept'}}
3 $.extend(true, obj1, obj2);

Covering everything about the behavior of JavaScript objects (and how
merge interacts with them) is beyond the scope of this article, but you can
read more here.


The difference between merge() and extend() in jQuery is not the same
as it is in MooTools. One is used to amend an existing object, the other
creates a new copy.


There You Have It


We’ve seen some similarities, but more often than not intricate (and
occasionally major) differences. jQuery is not a language, but it deserves to
be learned as one, and by learning it you will make better decisions about
what methods to use for which situation.


It should also be said that this article does not aim to be an exhaustive
guide to all jQuery functions available for every situation. For DOM
traversal, for example, there’s also nextUntil() and parentsUntil().


While there are strict rules these days for writing semantic and SEO-
compliant mark-up, JavaScript is still very much the playground of the
developer. No one will demand that you use click() instead of bind(),
but that’s not to say one isn’t a better choice than the other. It’s all about
the situation.

Free download pdf