1. 什么是反柯理化,怎么实现
反柯里化,是一个泛型化的过程。它使得被反柯里化的函数,可以接收更多参数。
Function.prototype.unCurrying = function(){
var that = this;
return function(){
return Function.prototype.call.apply(that,arguments);
}
}
2.实现mergeOptions方法
function mergeOptions(o1,o2){
if(o1 === undefined || o1 === null){
return o2;
}
else if(o2 === undefined || o2 === null){
return o1;
}
else{
for (const key in o2) {
if (!o1.hasOwnProperty(key)) {
//o1中不存在o2的某一个属性
o1[key] = o2[key];
}
else{
//o1中存在o2的某一个属性
if(o2[key] instanceof Array && o1[key] instanceof Array){
//o1和o2的这个属性都是数组
o1[key] = [...new Set([...o1[key]