-1
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

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
avisek
  • 45
  • 6
  • Do you ask the logic of the functions step-by-step? – vahdet Feb 27 '19 at 08:22
  • @vahdet this implementation i understood var hasAll = Object.keys(obj1).every(key => obj2.hasOwnProperty(key )); But the one mentioned in question how its similar to this one? – avisek Feb 27 '19 at 08:40

1 Answers1

1

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.

Emma
  • 27,428
  • 11
  • 44
  • 69
Nina Scholz
  • 376,160
  • 25
  • 347
  • 392