Node.JS – Shallow Copy Module
Hier ein einfaches Node.JS Module um eine „Shallow Copy“ eines Objektes anzufertigen. /** * A shallow copy of an object. */ function cloneObject(object) { if (object==null) returnobject; if (Array.isArray(object)) returnobject.slice(); if (‚object’===typeof (object)) { varclone= {}; Object.keys(object).forEach(function(key) { clone[key] = object[key]; // cloneObject(object[key]); }); return clone; } return object; } module.exports = …