-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassDemo.html
More file actions
33 lines (33 loc) · 1.04 KB
/
classDemo.html
File metadata and controls
33 lines (33 loc) · 1.04 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
<!DOCTYPE html>
<html>
<head></head>
<body>
<h1>Javascript classes and objects</h1>
<script>
class Student{
name ;
age;
static collage = "COEP";
//class construtor
constructor(name,age){
this.name = name;
this.age= age;
}
getStudentInfo(){
console.log(`Name : ${this.name} Age:${this.age} collage:${Student.collage}`);
}
}
let stu1 = new Student();
stu1.name ="Shobha" ;stu1.age=20;
let stu2 = new Student();
stu2.name="saritha" ; stu2.age = 18;
stu1.getStudentInfo();
stu2.getStudentInfo();
//object creating by consturtor of another object
let stu3 = new Student("James", 18);
stu3.getStudentInfo();
let stu4 = new Student("Tom" , 20);
stu4.getStudentInfo();
</script>
</body>
</html>