-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass.js
38 lines (36 loc) · 1017 Bytes
/
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
// class createMail {
// constructor(to, from, url) {
// this.to = to;
// this.from = from;
// this.url = url;
// }
// getSender() {
// return 'Sender is ' + this.from;
// }
// }
// var newMail = new createMail('[email protected]', '[email protected]', 'www.google.com');
// console.log(newMail.getSender());
// //function constructor
// function ObjectMaker(name,properties){
// this.Name=name;
// this.features=properties;
// this.getFeatures=function(){
// console.log("Features of "+this.Name+" are "+this.feature);
// };
// }
// var Bat=new ObjectMaker("Bat","Wooden");
// var Bike=new ObjectMaker("Harley","Hybrid");
// console.log(Bat);
//after ES6
class ObjectMaker{
constructor(name,properties,fn){
this.Name=name;
this.feature=properties;
this.myfn=fn;
}
getFeatures(){
console.log("Features of "+this.Name+" are "+this.feature);
}
}
var Bat=new ObjectMaker("Bat","Wooden");
console.log(Bat);