Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

create.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var baseAssign = require('./_baseAssign'),
  2. baseCreate = require('./_baseCreate');
  3. /**
  4. * Creates an object that inherits from the `prototype` object. If a
  5. * `properties` object is given, its own enumerable string keyed properties
  6. * are assigned to the created object.
  7. *
  8. * @static
  9. * @memberOf _
  10. * @since 2.3.0
  11. * @category Object
  12. * @param {Object} prototype The object to inherit from.
  13. * @param {Object} [properties] The properties to assign to the object.
  14. * @returns {Object} Returns the new object.
  15. * @example
  16. *
  17. * function Shape() {
  18. * this.x = 0;
  19. * this.y = 0;
  20. * }
  21. *
  22. * function Circle() {
  23. * Shape.call(this);
  24. * }
  25. *
  26. * Circle.prototype = _.create(Shape.prototype, {
  27. * 'constructor': Circle
  28. * });
  29. *
  30. * var circle = new Circle;
  31. * circle instanceof Circle;
  32. * // => true
  33. *
  34. * circle instanceof Shape;
  35. * // => true
  36. */
  37. function create(prototype, properties) {
  38. var result = baseCreate(prototype);
  39. return properties == null ? result : baseAssign(result, properties);
  40. }
  41. module.exports = create;