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

has.js 663B

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