-
Notifications
You must be signed in to change notification settings - Fork 0
/
object.js
70 lines (50 loc) · 1.3 KB
/
object.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//in js object are like key value pair
// let obj = {};
// console.log(obj);
// let person = {
// name:"Aman",
// age:45,
// phone:1234567,
// isMale:true
// }
// console.log(person);
//dot notation
// console.log(person.age);
// console.log(person.name);
//bracket notation
// let c = "age";
// console.log(person[c]);
let capAmerica = {
name:"Steve Rogers",
age:999999,
friends:["Bucky","Tony","Natasha","Sam","Bruce"],
sayHi:function(){
console.log("Steve says Hi")
},
address:{
country:"USA",
city:{
state:"Queen",
pincode:12345
}
},
isAvenger : false
}
// console.log(capAmerica.age);
// console.log(capAmerica["age"]);
// console.log(capAmerica.friends[0]);
// console.log(capAmerica["friends"][0]);
//console.log(capAmerica.address.city.state)
// console.log(capAmerica["address"]["city"]["state"]);
// console.log(capAmerica);
// //update an existing value;
// capAmerica.isAvenger = true;
// console.log(capAmerica)
// // add an key value pair to capAmerica object
// capAmerica.movies = ["First Avenger","End Game","Civil war"]
// console.log(capAmerica)
// //delete an existing key value pair
// delete capAmerica.age;
// console.log(capAmerica);
// console.log(capAmerica.sayHi);
capAmerica.sayHi();