isObject.js 717 B

1234567891011121314151617181920212223242526272829
  1. // @ts-nocheck
  2. /**
  3. * Checks if `value` is the
  4. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  5. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  6. *
  7. * @since 0.1.0
  8. * @category Lang
  9. * @param {*} value The value to check.
  10. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  11. * @example
  12. *
  13. * isObject({})
  14. * // => true
  15. *
  16. * isObject([1, 2, 3])
  17. * // => true
  18. *
  19. * isObject(Function)
  20. * // => true
  21. *
  22. * isObject(null)
  23. * // => false
  24. */
  25. function isObject(value) {
  26. const type = typeof value;
  27. return value != null && (type === "object" || type === "function");
  28. }
  29. export default isObject;