- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstructorFunction.js
More file actions
Latest commit
33 lines (28 loc) · 669 Bytes
/
Copy pathConstructorFunction.js
File metadata and controls
33 lines (28 loc) · 669 Bytes
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
functionPerson(name,age){
this.name=name;
this.age=age;
}
functionCar(make,model){
this.make=make;
this.model=model;
}
letmyCar=newCar("Toyota","Kia");
console.log(myCar);
letmyNewCar=newCar("Mahindra","Safari");
console.log(myNewCar);
functionTea(type){
this.type=type;
this.describe=functionTea(type){
return`This is a Cup of ${this.type}`;
};
}
letlemontea=newTea("Lemon tea");
console.log(lemontea.describe());
functionDrink(name){
if(!new.target){
thrownewError("Drink must be called with the new keyword");
}
this.name=name;
}
lettea=newDrink("tea");
letcoffee=Drink("coffee");