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.

clone.js 401B

12345678910111213141516171819
  1. 'use strict'
  2. module.exports = clone
  3. function clone (obj) {
  4. if (obj === null || typeof obj !== 'object')
  5. return obj
  6. if (obj instanceof Object)
  7. var copy = { __proto__: obj.__proto__ }
  8. else
  9. var copy = Object.create(null)
  10. Object.getOwnPropertyNames(obj).forEach(function (key) {
  11. Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key))
  12. })
  13. return copy
  14. }