Last active
December 23, 2015 17:09
-
-
Save sapher/6666550 to your computer and use it in GitHub Desktop.
Check if keys exists in hash with Underscore.js
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
//Hash of data | |
data = { | |
longitude : 1, | |
latitude : 1 | |
}; | |
//Required keys | |
var requiredKeys = ['longitude', 'latitude']; | |
//Return true | |
console.log(_.every(requiredKeys, _.partial(_.contains, _.keys(data)))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment