Skip to content

Instantly share code, notes, and snippets.

@kitsune7
Created September 26, 2018 05:08
Show Gist options
  • Save kitsune7/b65b31e149dd7d3e330fa0ceeff2e558 to your computer and use it in GitHub Desktop.
Save kitsune7/b65b31e149dd7d3e330fa0ceeff2e558 to your computer and use it in GitHub Desktop.
A function that checks whether or not a JSON object has all the properties that were passed to it.
/**
* @param object json
* @param string[] properties
* @returns boolean
*/
function jsonHasProperties (json, properties) {
return properties.every(prop => json.hasOwnProperty(prop))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment