-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
  • 107,083
  • 22
  • 201
  • 376
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
  • 26,487
  • 10
  • 35
  • 65
Nina Scholz
  • 351,820
  • 24
  • 303
  • 358