MichaƂ Wadas (2015-02-23T09:10:41.000Z)
Cloning objects is long requested feature.
"clone object javascript" yields 1 480 000 results in Google.

My proposition is to create a new well known Symbol - Symbol.clone and
corresponding method on Object - Object.clone.

Default behavior for an object is to throw on clone try.
Object.prototype[Symbol.clone] = () => { throw TypeError; }
Users are encorauged to define their own Symbol.clone logic.

Primitives are cloned easily.
Number.prototype[Symbol.clone] = String.prototype[Symbol.clone] =
Boolean.prototype[Symbol.clone] = function() {return this.valueOf();}


Sets, Dates, Maps, WeakMaps, WeakSets have cloned their internal state.
Set.prototype[Symbol.clone] = function() {return new Set(this);}
(cloning WeakMap or WeakSet isn't possible in ES6 code anyway)

Every object returned from JSON.parse can be cloned if all it's
subnodes are clonable.

Arrays can be cloned if all it's items are clonable.

Moreover, it can be used as future way to clone iterators.
d at domenic.me (2015-03-03T21:22:16.974Z)
Cloning objects is long requested feature.
"clone object javascript" yields 1 480 000 results in Google.

My proposition is to create a new well known Symbol - Symbol.clone and
corresponding method on Object - Object.clone.

Default behavior for an object is to throw on clone try.

```js
Object.prototype[Symbol.clone] = () => { throw TypeError; }
```

Users are encorauged to define their own Symbol.clone logic.

Primitives are cloned easily.

```js
Number.prototype[Symbol.clone] = String.prototype[Symbol.clone] =
Boolean.prototype[Symbol.clone] = function() {return this.valueOf();}
```


Sets, Dates, Maps, WeakMaps, WeakSets have cloned their internal state.
Set.prototype[Symbol.clone] = function() {return new Set(this);}
(cloning WeakMap or WeakSet isn't possible in ES6 code anyway)

Every object returned from JSON.parse can be cloned if all it's
subnodes are clonable.

Arrays can be cloned if all it's items are clonable.

Moreover, it can be used as future way to clone iterators.