You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Object_part2.js
+104-1
Original file line number
Diff line number
Diff line change
@@ -8,5 +8,108 @@ const tinderuser= new Object() //sigleton object
8
8
tinderuser.age=18
9
9
tinderuser.IsLogIn=true
10
10
11
-
console.log(tinderuser);
11
+
// console.log(tinderuser);
12
12
13
+
// nested object : means object in object
14
+
// declearation
15
+
constregularUser={
16
+
email:"Some@gmail.com",
17
+
fullname:{//fullname is object
18
+
userfirstName:"abhishek",
19
+
userLastName:"pandey"
20
+
}
21
+
}
22
+
23
+
// we can acces nested object by dot
24
+
// we will use ? if will conect by api response otherwise we will need to use ifelse means if object is availiable then will give output otherwise leave
constobj3=Object.assign(Obj1,Obj2)//output :{ a: 45, b: 67, c: 85, d: 35 } , first will get target means empaty it will modify target by sorce by merge and will give target as a new object
37
+
38
+
// Object.assign(target,sorce one or more seprate by commas)
39
+
//all values will combine and new object will get
40
+
// will create a new object as object1,and Object2
41
+
console.log(obj3);
42
+
console.log(Obj1);
43
+
44
+
// one more spread method for combine object as we done in array
45
+
constobj3_={...Obj1,...Obj2}//it is a very simplest way for combine
46
+
47
+
// data come from database as many object in array
48
+
49
+
constdata_=[
50
+
{
51
+
username:"avi898",
52
+
password:"6869896"
53
+
},
54
+
{
55
+
username:"dsfji898",
56
+
password:"6869896"
57
+
},
58
+
{
59
+
username:"avinas898",
60
+
password:"6869896"
61
+
}
62
+
,
63
+
{
64
+
}
65
+
]
66
+
67
+
// console.log(data_[1].password);//here we written 1 because we all looking from array so we will give index then we will get value from object
68
+
69
+
// console.log(Object.keys(tinderuser)); //when we will use Object then we need to tell about which object we all talking
70
+
// we will get output in array mean now we can put loop on that
71
+
// it is very important
72
+
73
+
// as we get keys as array we can get value also as array
74
+
// console.log(Object.values(tinderuser));
75
+
76
+
77
+
// console.log(Object.entries(tinderuser));// by entries will create each keys and value as a value
78
+
79
+
// very important in what data user or we are performing loop want we have not then can crash so we will use a property for check is value availiable in Object if will avaliable we will get output true otherwise false
0 commit comments