I began writing code assuming that:
person1 = person
will give me a new instance, it doesn't. person1
is actually a reference/pointer to person
.
person = {age : 2}
person1 = person;
person.age = 3;
alert(person1.age); //gives us 3.
How do I make a new instance without changing much code around? I have like 300 lines of code inside the object, functions(methods?) and everything. Wouldn't want to rewrite as a constructor.