HasOwnProperty.js 509 B

1234567891011121314151617181920
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. var hasOwn = require('hasown');
  4. var IsPropertyKey = require('./IsPropertyKey');
  5. var Type = require('./Type');
  6. // https://262.ecma-international.org/6.0/#sec-hasownproperty
  7. module.exports = function HasOwnProperty(O, P) {
  8. if (Type(O) !== 'Object') {
  9. throw new $TypeError('Assertion failed: `O` must be an Object');
  10. }
  11. if (!IsPropertyKey(P)) {
  12. throw new $TypeError('Assertion failed: `P` must be a Property Key');
  13. }
  14. return hasOwn(O, P);
  15. };