-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.js
47 lines (34 loc) · 1 KB
/
class.js
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
/* class */
//syntax
/*
class model{ //model is the name of the class
constructor(){
//body
}
}
//create instance of class
const obj1=new model();
const obj2=new model(); //multiple instance of the class
//use of instanceof keyword
console.log(obj1 instanceof model); //prints true
*/
//example
/*
class model{
constructor(Mno,Mname){ //Mno and Mname are parameters
//this.Mno=Mno and this.Mname=Mname are properties
//assigning values to properties from parameters
this.Mno=Mno;
this.Mname=Mname;
}
//create method
Show(){
console.log(`model number:${this.Mno}, model name:${this.Mname}`);
}
}
//create instance of class
const obj1=new model(234,"nin");
obj1.Show();
const obj2=new model(476,"asf");
obj2.Show();
*/