-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjects.js
More file actions
52 lines (42 loc) · 947 Bytes
/
Copy pathObjects.js
File metadata and controls
52 lines (42 loc) · 947 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
// Objects in java script
const afaq = {
name : "Afaq",
age : 21,
gender : "Male",
Height : "5,4"
};
// Accessing types
// Dot notation
console.log(afaq.name);
// Bracket notation
console.log(afaq["gender"]);
// add new
afaq.color = "Brown";
// delete
delete afaq.color;
// Object can contain the function as well
const student = {
name : "Afaq",
Gretting : function (){
console.log("Hello")
},
};
console.log (student)
// The whole object will be shown the function and the name
Gretting()
// Now only the function will be called
// Object in an object (Nested Object)
const student = {
name : "Afaq",
age : 21,
gender : "Male",
Height : "5,4",
marks : {
phy : 34,
math : 40,
SE : 88
},
};
// for accessing the nested we willl use
console.log(student.marks.phy);
// this is how it's done