en.javascript.info/1-js/9-object-inheritance/07-constructor-property/4-new-object-same-constructor/task.md
Ilya Kantor b0976b5253 up
2016-11-14 23:41:18 +03:00

15 lines
416 B
Markdown

importance: 5
---
# Create an object with the same constructor
Imagine, we have an arbitrary object `obj`, created by a constructor function -- we don't know which one, but we'd like to create a new object using it.
Can we do it like that?
```js
let obj2 = new obj.constructor();
```
Give an example of a constructor function for `obj` which lets such code work right. And an example that makes it work wrong.