Skip to content

Instantly share code, notes, and snippets.

@youxiachai
Created June 30, 2014 08:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youxiachai/cac279e986ce4fb6ca24 to your computer and use it in GitHub Desktop.
Save youxiachai/cac279e986ce4fb6ca24 to your computer and use it in GitHub Desktop.
js 各种黑科技写法
var x = {
a : 1,
b : 2,
c : 3
}
var y = {
b : 5
}
Object.keys(x).forEach(function (item){
console.log(item)
if(item === 'a'){
return
}
if(x[item] && y[item] !== x[item]){
y[item] = x[item];
}
})
console.log(y)
@youxiachai
Copy link
Author

两对象间,返回对象参数不同的值

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