Created
April 21, 2016 14:04
-
-
Save SeanJM/dda10ad4ab9e230a3d557237203e37cd to your computer and use it in GitHub Desktop.
A function to see if an object has a key
This file contains hidden or 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
function hasKey (object, key) { | |
for (var k in object) { | |
if (k === key && object.hasOwnProperty(key)) { | |
return true; | |
} | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment