General API
len()
Computes the total length of the passed arguments.
- Accepts arguments as strings, numbers, arrays, objects, sets, maps, functions, NodeLists, and HTMLCollections.
- Returns the length of the passed arguments.
If multiple arguments are provided, their lengths are summed.
Example:
len(1.5);
// 3
len('book');
// 4
len([123, 'book', {key: 'value'}]);
// 3
len({key: 'value', key2: 'value2'});
// 2
len(function example(a, b, c) {});
// 3
len('123', [4, 5, 6]);
// 6
len(123, '123', [1, 2], {key: 'value'});
// 9
len(new Set([1, 2, 3, 4, 5]));
// 5
len(new Map([['a', 1], ['b', 2], ['c', 3]]));
// 3
len($('body ?'));
len(document.querySelectorAll('body'));
len(document.getElementsByTagName('body'));
// 1