-
Notifications
You must be signed in to change notification settings - Fork 0
/
day19.html
72 lines (58 loc) · 1.68 KB
/
day19.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Js Objects</title>
</head>
<body>
<!--
Javascript Objects -> It is a collection of properties and methods
Properties -> It is a value associated with a object
1. Object Literals
2. Constructor
3. Object Oriented Programming
JavaScript variables can also contain many values.
Objects are variables too. But objects can contain many values.
Object values are written as name : value pairs (name and value separated by a colon).
-->
<script>
// Object Literals
const Jsuser = {
name: "Lokesh Singh",
Address: "TCP Tekanpur Gwalior",
Phone: 7985218361,
email: "[email protected]",
working_days: [
"Monday",
"Tuesday",
"wednesday",
"Thursday",
"Friday",
"Saturday",
],
greet: (greeting = () => {
console.log("I am function in Js object");
}),
"course name": "Javascript",
};
// Accesing the obj
// Method -1
console.log(Jsuser.name);
// Method-2 (If the Property have space in between)
console.log(Jsuser["course name"]);
console.log(
"The working days of ",
Jsuser.name,
"are : ",
Jsuser.working_days
);
// Change value of obj
console.log(Jsuser.name);
Jsuser.name = "Lokesh";
console.log(Jsuser.name);
console.log(Jsuser.greet);
console.log(Jsuser.greet());
</script>
</body>
</html>