Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // BOTH WAYS WORK !!! :)
- function clone(obj) {
- return Object.create(obj);
- //return JSON.parse(JSON.stringify(obj));
- }
- function compareObjects(obj, objCopy) {
- console.log('a == b --> ' + (obj == objCopy));
- }
- var a = { name: 'Pesho', age: 21 };
- var b = clone(a); // a deep copy
- compareObjects(a, b);
- var a = { name: 'Pesho', age: 21 };
- var b = a; // not a deep copy
- compareObjects(a, b);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement