var hasAll = Object.keys(obj1).every(Object.prototype.hasOwnProperty.bind(obj2));
This code I have taken is from a solution to Best way to Check a JavaScript Object has all the keys of another JavaScript Object
var hasAll = Object.keys(obj1).every(Object.prototype.hasOwnProperty.bind(obj2));
This code I have taken is from a solution to Best way to Check a JavaScript Object has all the keys of another JavaScript Object
It borrows Object#hasOwnProperty
from the prototype of Object
and uses bj2
as this
object with binding (Function#bind
).
The result is a function, which can be used as callback.