-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScript_fourth.html
More file actions
37 lines (34 loc) · 1.1 KB
/
JavaScript_fourth.html
File metadata and controls
37 lines (34 loc) · 1.1 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Arrays and class in JavaScript</title>
<script>
// Arrays //
let arr = [1, 2, 2.4, "Saurav", true];
console.log(arr);
let obj_arr = new Array(1, 2, 2.4, "Saurav", true);
console.log(obj_arr);
arr.push("Kumar");
console.log(arr);
console.log(arr.length);
console.log(arr[3]);
// Objects //
let student = {
name : "Saurav",
roll : "17CH30049",
CGPA : 8.59,
"semester number": 8 // key can have space, we just need to write it in quote then
};
console.log(student);
console.log(student.name);
console.log(student["name"]);
console.log(student["semester number"]); // here we can't use . operator to access now
</script>
</head>
<body>
<h1>Arrays and Object in JavaScript</h1>
</body>
</html>