-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjsclasswithoutconstructor.html
37 lines (36 loc) · 1.33 KB
/
jsclasswithoutconstructor.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
<!DOCTYPE html>
<html>
<head>
<link type="stylesheet" src="css/index.css"> <!--link of external css file -->
<script type="text/javascript" src="js/index.js"></script> <!--link of external JS file -->
</head>
<body style="text-align: center;">
<h1>Welcome To JavaScript Basics</h1>
<p id="demo"></p>
</body>
<script>
class sname{
displayFullName = (fname,lname) =>{
var firstName = fname;
var lastName = lname;
return("<br>"+firstName+" "+lastName+"<br>");
}
}
class result extends sname{
total_Sub = 7 //without constructor variable declare
calculate = (num) =>{
return("got marks: "+(num/7)+"<br>");
}
}
let student1 = new result();
let student2 = new result();
var studentdata = [
[student1.displayFullName("Krishnendu","Nandy"),student1.calculate(563)],
[student2.displayFullName("Rahul","Das"),student2.calculate(583)]
]
for(var i in studentdata){
document.write(studentdata[i]);
}
// document.getElementById("helloWorld").innerHTML = "Hello!!"; //Change the content of html from JavaScript>
</script>
</html>