File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -728,6 +728,34 @@ let user = {
728728const {fullName : {first}} = user;
729729console.log(first); //"Priya"
730730//Destructuring at deep nested
731+ -------------------------------------------------------------------------------------------
732+ let c = {greeting : "Hey!"}
733+ let d;
734+
735+ d=c;
736+ c.greeting = "Hello"
737+ console.log(d.greeting); //Hello
738+ //We are passing the refrence not the propertues of an object so when we changge the roperty of any object it will reflect in both objects
739+ -------------------------------------------------------------------------------------------
740+ let person = {name : "priya"}
741+ const members = [person]
742+ person = null
743+ console.log(members);// [{"name":"priya"}]
744+
745+ let person = {name : "priya"}
746+ const members = [person]
747+ person.name = null
748+ console.log(members);// [{"name":null}]
749+ //because we are modifying the property of object
750+ -------------------------------------------------------------------------------------------
751+ Ways to make deep copy:
752+ 1. object.assign
753+ 2. {...obj}
754+ 3. JSON.parse(JSON.stringyfy(obj))
755+ -------------------------------------------------------------------------------------------
756+
757+ -------------------------------------------------------------------------------------------
758+
731759-------------------------------------------------------------------------------------------
732760
733761-------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments