Why is Object.keys faster than hasOwnProperty?

  • Object.keys looks up all own, enumerable properties (oh, and arrays are fast).
  • for in additionally looks up inherited enumerable properties, not only own ones
  • for in + hasOwnProperty additionally tests all looked up properties for whether they are own properties.

Even if there are no inherited enumerable properties, it is still more work to do than not.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)