Skip to content

Instantly share code, notes, and snippets.

@sapher
Last active December 23, 2015 17:09
Show Gist options
  • Save sapher/6666550 to your computer and use it in GitHub Desktop.
Save sapher/6666550 to your computer and use it in GitHub Desktop.
Check if keys exists in hash with Underscore.js
//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