blob: b341654e7caa0a8de4424ef71dae9ad5d7e3ea4a [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3var GetIntrinsic = require('get-intrinsic');
4
5var $TypeError = GetIntrinsic('%TypeError%');
6
7var IsPropertyKey = require('./IsPropertyKey');
8var Type = require('./Type');
9
10// https://ecma-international.org/ecma-262/6.0/#sec-hasproperty
11
12module.exports = function HasProperty(O, P) {
13 if (Type(O) !== 'Object') {
14 throw new $TypeError('Assertion failed: `O` must be an Object');
15 }
16 if (!IsPropertyKey(P)) {
17 throw new $TypeError('Assertion failed: `P` must be a Property Key');
18 }
19 return P in O;
20};