Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

has.js 650B

123456789101112131415161718192021
  1. import isArray from './isArray.js';
  2. import _has from './_has.js';
  3. import { hasOwnProperty } from './_setup.js';
  4. // Shortcut function for checking if an object has a given property directly on
  5. // itself (in other words, not on a prototype). Unlike the internal `has`
  6. // function, this public version can also traverse nested properties.
  7. export default function has(obj, path) {
  8. if (!isArray(path)) {
  9. return _has(obj, path);
  10. }
  11. var length = path.length;
  12. for (var i = 0; i < length; i++) {
  13. var key = path[i];
  14. if (obj == null || !hasOwnProperty.call(obj, key)) {
  15. return false;
  16. }
  17. obj = obj[key];
  18. }
  19. return !!length;
  20. }