Last active
December 21, 2015 08:28
-
-
Save otiai10/6278400 to your computer and use it in GitHub Desktop.
これもっと良い実装知りませんか?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var obj = { | |
'hoge' : 1, | |
'fuga' : 2, | |
'unko' : 3, | |
'piyo' : 4, | |
}; | |
// unkoだけ削除したい | |
var remove = function(_k, _obj){ | |
var updated = {}; | |
for(var key in _obj){ | |
if(key != _k) updated[key] = _obj[key]; | |
} | |
return updated; | |
} | |
console.log(obj); | |
console.log(remove('unko',obj)); | |
/* | |
{ hoge: 1, fuga: 2, unko: 3, piyo: 4 } | |
{ hoge: 1, fuga: 2, piyo: 4 } | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment