Creating ImagesInc_Utilites module

Since a utilities module is a good place to implement our object cloning code, let's create our ImagesInc_Utilites module as follows:

var ImagesInc_Utilitizes = (function(){ var clone = function clone(deep) { // create an instance of the object var newClonedObj = new this.constructor(); //copy all properties from the original object for (var property in this){ // if deep flag is not set, just do a shallow copy of properties if (!deep){ if(this.hasOwnProperty(property)){ newClonedObj[property] = this[property]; } // to make a deep copy, call the function recursively }else if (typeof this[property] == 'object' && this.hasOwnProperty(property)){ newClonedObj[property] = this[property].clone(deep); }else if(this.hasOwnProperty(property)){ ...

Get Modular Programming with JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.