javascript - Prototypical inheritance for cloned object - IE10 -


i’m trying clone object, using lodash’ _.clone.

however, want keep prototypical inheritance intact cloned object. ie 10 not letting me access __proto__ or object.setprototypeof(toobj, object.getprototypeof(fromobj)); , don’t want access via call or apply on parent object there lot of setter , getter method on parent need called clone object.

any suggestion?

after try, found 1 of use:

/**  * shallow clone object , retains prototype chain  * @param   {object} fromobj object cloned  * @returns {object} cloned object  */ function cloneobj(fromobj) {   var toobj, i;    if (fromobj && typeof fromobj === 'object') {     toobj = new fromobj.constructor();      (i in fromobj) {       if (fromobj.hasownproperty(i)) {         toobj[i] = fromobj[i];       }     }   } else {     throw new error(fromobj + ' cannot cloned');   }    return toobj; } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -