var BaiduUsers = [], WechatUsers = [];var User = function(id, name, phone, gender, age, salary) {this.id = id;this.name = name;this.phone = phone;this.gender = gender;this.age = age;this.salary = salary;};User.create = function(id, name, phone, gender, age, salary) { return new User(id, name, phone, gender, age, salary);};BaiduUsers.push(User.create(1, 'tommy', '1111','male', 18, 10000));BaiduUsers.push(User.create(2, 'jerry', '2222','male', 28, 10000));BaiduUsers.push(User.create(3, 'raobin','3333','female', 14, 1200));BaiduUsers.push(User.create(4, 'binbin','4444','male', 23, 9800));BaiduUsers.push(User.create(5, 'arthur','5555','female', 22, 10000));WechatUsers.push(User.create(1, 'tommy', '1111','male', 20, 40000));WechatUsers.push(User.create(2, 'allen', '6666','male', 34, 15800));WechatUsers.push(User.create(3, 'raobin','3333','female',16, 2300));WechatUsers.push(User.create(4, 'harvey','7777','male',30, 29800));WechatUsers.push(User.create(5, 'yuyu', '8888','female',27, 7000));var newusers = [];var len1=WechatUsers.length;var len =WechatUsers.length+1;newusers =myFunction(newusers);function myFunction(user){for (var i = 0; i < BaiduUsers.length; i++) {for (var y = 0; y< WechatUsers.length; y++) {if (BaiduUsers[i].phone==WechatUsers[y].phone){newusers.push(User.create(WechatUsers[y].id,WechatUsers[y].name,WechatUsers[y].phone,WechatUsers[y].gender,WechatUsers[y].age,WechatUsers[y].salary+BaiduUsers[i].salary)); } else {newusers.push(User.create(len++,BaiduUsers[i].name,BaiduUsers[i].phone,BaiduUsers[i].gender,BaiduUsers[i].age,BaiduUsers[i].salary*1.2)); }} }return user}var hash = {};newusers = newusers.reduce(function(item, next) { hash[next.phone] ? '' : hash[next.phone] = true && item.push(next); return item}, [])console.log(newusers);var newusers2= [];newusers2 =myFunction(newusers2);function myFunction(user){for (var i = 0; i < WechatUsers.length; i++) {for (var y = 0; y< newusers.length; y++) {if (newusers[i].phone!=WechatUsers[y].phone){newusers2.push(User.create(WechatUsers[i].id,WechatUsers[i].name,WechatUsers[i].phone,WechatUsers[i].gender,WechatUsers[i].age,WechatUsers[i].salary)); } } }return user}var hash = {};newusers2 = newusers2.reduce(function(item, next) { hash[next.phone] ? '' : hash[next.phone] = true && item.push(next); return item}, [])console.log(newusers2);