JS 合并option

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var merge=function (target){
console.log(arguments);
  for (let i = 1, j = arguments.length; i < j; i++) {
    let source = arguments[i] || {};
    for (let prop in source) {
      if (source.hasOwnProperty(prop)) {
        let value = source[prop];
        if (value !== undefined) {
                    if(typeof value!='object'){
                        target[prop] = value;
                    }
                    else{
                         merge(target[prop],value);
                    }
           
        }
                 
      }
    }
  }
    
  return target;
};

  

posted @   Observer_Dep  阅读(78)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示