if (typeof Object.assignWhenSame != 'function') {
Object.defineProperty(Object, "assignWhenSame", {
value: function assignWhenSame(target, varArgs) {
'use strict';
if (target == null) {
throw new TypeError('Cannot convert undefined or null to object');
}
var to = new Object(target);
for (var index = 1; index < arguments.length; index++) {
var nextSource = arguments[index];
if (nextSource != null) {
for (var nextKey in nextSource) {
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey) && Object.prototype.hasOwnProperty.call(target, nextKey)) {
to[nextKey] = nextSource[nextKey];
}
}
}
}
return to;
},
writable: true,
configurable: true
});
}
console.log(Object.assignWhenSame({
a: 1
},
{
a: 2,
b: 3
}));
console