-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchap5.js
More file actions
75 lines (63 loc) · 984 Bytes
/
chap5.js
File metadata and controls
75 lines (63 loc) · 984 Bytes
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
71
72
73
74
75
//Objects
//Declaration
/*
let student={
name:"mg",
age:21,
rollno:23,
marks:75
};
//console.log(student);
*/
//fetch any particular property
/*
//Using dot (.) operator
console.log(student.age);
//Using square bracket
console.log(student["marks"]);
*/
//Update
/*
student.marks=80;
console.log(student);
*/
//Insert extra property
/*
student.isMarried=false;
console.log(student);
*/
//Delete property from object
/*
delete student.age;
console.log(student);
*/
//Iterate properties
/*
//Only keys
for(let x in student)
{
console.log(x);
}
//Keys with values
for(let y in student)
{
console.log(y+": "+student[y]);
}
*/
//Nested object
/*
let student = {
name: "mg",
age: 21,
rollno: 23,
marks: 75,
address: {
houseno: 160,
Pincode: 248007,
State: "Uttar Pradesh"
}
};
console.log(student);
///Fetching nested obejct property
console.log(student.address.Pincode);
*/