Skip to content

Commit 81b4522

Browse files
authored
Update 100_JS_Que
1 parent 696c134 commit 81b4522

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

100Questions/100_JS_Que

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,34 @@ let user = {
728728
const {fullName : {first}} = user;
729729
console.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
-------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)