Answers for "how to create an object with new reference javascrip"

4

clone javascript object

let clone = Object.assign({}, objToClone);
Posted by: Guest on February-19-2020
-1

clone an object javascript

//returns a copy of the object
function clone(obj) {
    if (null == obj || "object" != typeof obj) return obj;
    var copy = obj.constructor();
    for (var attr in obj) {
        if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr];
    }
    return copy;
}
Posted by: Guest on January-28-2020

Code answers related to "how to create an object with new reference javascrip"

Code answers related to "Javascript"

Browse Popular Code Answers by Language