blob: 132c4d58480f74f2cb987dd997783c035d313a43 [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 Get = require('./Get');
8var ToLength = require('./ToLength');
9var Type = require('./Type');
10
11// https://262.ecma-international.org/11.0/#sec-lengthofarraylike
12
13module.exports = function LengthOfArrayLike(obj) {
14 if (Type(obj) !== 'Object') {
15 throw new $TypeError('Assertion failed: `obj` must be an Object');
16 }
17 return ToLength(Get(obj, 'length'));
18};
19
20// TODO: use this all over