Dojo works a bit differently than we saw with jQuery and ExtJS. They have the notion of extend as well as mixin. These both behave differently, not only from each other, but from the previous jQuery.extend and Ext.apply. These methods in Dojo work right to left, different from our previous examples.
Let’s discuss mixin, this is more like what we previously saw with previous libraries’ methods:
And the output:
If you remember from the previous posts, we extended our start, more, and extra objects from left to right. Using a Dojo mixin, our arguments are passed to the function in the reverse order; this is by design. Everything in our output of the extended object remains as it was in our start object. The only difference is that more added the name property and extra added the dojo property. This works just like you’d expect a mixin function to work and just like our previous extend and apply from jQuery and Ext JS.
The dojo.extend function works on an object’s prototype and doesn’t follow the same patterns of this series of blog posts. For that reason, I’m going to skip it and let you do your own homework if you’re interested. ;)
For more information: dojo.mixin (Yes I know this way to reference dojo is deprecated, but the old version worked better in my tiny example.)
Post Footer automatically generated by Add Post Footer Plugin for wordpress.