melanke / Watch.JS

watch the changes of any object or attribute

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Class instance new properties

LMnet opened this issue · comments

Look at this fiddle: http://jsfiddle.net/tYRn5/
It fails on 11 line. I found, that problem occurs in clone function, on line 100:

var copy = obj.constructor();

In case of class instance, it must be something like this:

var copy = new obj.constructor();

Just for adding some considerations, look at this stackoverflow post on how to clone an object: http://stackoverflow.com/a/728694

"To do this for any object in JavaScript will not be simple or straightforward."