Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const _ = require('lodash');
- const obj = [{
- x: 1
- }, {
- y: 2,
- z: {
- 1: "string"
- },
- sym: Symbol('foo'),
- func: function() {
- console.log("Hey!");
- }
- }];
- const deepCopy = _.cloneDeep(obj);
- deepCopy.funcTwo = function() {
- console.log("BYE!");
- };
- deepCopy.symTwo = Symbol("foo");
- console.log('Comparing original with deep ',
- obj[0] === deepCopy[0]);
- // Changing original value
- obj[0].x = 10;
- console.log("After changing original value");
- console.log("Original value ", obj);
- console.log("Deep Copy value ", deepCopy);
- console.log(obj.sym === deepCopy.sym);
- console.log(obj.sym === deepCopy.symTwo);
- console.log(obj.func === deepCopy.func);
- console.log(deepCopy.funcTwo === deepCopy.func);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement