[Solved] copy all the properties of config to obj unless they already exist in obj


var obj ={ name : ‘x’, age:50, color : ‘clo’};var config ={ name:’suhaib’,id:25}; copyif(obj,config); function copyif(obj, config) { for (var prop in obj) { if (obj.hasOwnProperty(prop)) { if(!config.hasOwnProperty(prop)) config[prop] = obj[prop]; } } console.log(config); }

var obj ={ name : 'x', age:50, color : 'clo'};var config ={ name:'suhaib',id:25}; copyif(obj,config); function copyif(obj, config) { for (var prop in obj) { if (obj.hasOwnProperty(prop)) { if(!config.hasOwnProperty(prop)) config[prop] = obj[prop]; } } console.log(config); }

solved copy all the properties of config to obj unless they already exist in obj