Skip to content

Instantly share code, notes, and snippets.

@XiongJingzhi
Created January 3, 2019 01:31
Show Gist options
  • Save XiongJingzhi/4d19488ffd0de8c64fc73b8a9a4b7bbe to your computer and use it in GitHub Desktop.
Save XiongJingzhi/4d19488ffd0de8c64fc73b8a9a4b7bbe to your computer and use it in GitHub Desktop.
'use strict';
const merge = (target, source) => {
const keys = Object.keys(target);
keys.forEach(k => {
if (source.hasOwnProperty(k)) {
if (Object.prototype.toString.call(source[k]) === '[object Object]') {
merge(target[k], source[k]);
} else {
target[k] = source[k];
}
}
});
};
module.exports = merge;
@XiongJingzhi
Copy link
Author

写的妙

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment