UNPKG

util-ex

Version:

Browser-friendly enhanced util fully compatible with standard node.js

20 lines (18 loc) 655 B
const argsClass = '[object Arguments]'; /** * Checks if a value is an `arguments` object. * @param {*} value - The value to check. * @returns {boolean} Returns `true` if `value` is an `arguments` object, else `false`. * @example * ```js * function myFunction() { * return isArguments(arguments); * } * console.log(myFunction()); // true, since the `arguments` object is an instance of `Arguments` * isArguments([1, 2, 3]); // => false * ``` */ export function isArguments(value) { return value && typeof value === 'object' && typeof value.length === 'number' && toString.call(value) === argsClass || false; }; export default isArguments;