- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoop-master.js
More file actions
Latest commit
55 lines (48 loc) · 1.13 KB
/
Copy pathoop-master.js
File metadata and controls
55 lines (48 loc) · 1.13 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
functionCar(){
this.make="Toyota";
this.model="Safari";
this.year=2018;
this.start=function(){
return`${this.make} car is started in ${this.year}`;
}
}
letmyCar=newCar();
console.log(myCar.start());
functionPerson(name,age){
this.name=name;
this.age=age;
}
letjohn=newPerson("John",22)
console.log(john);
functionAnimal(type){
this.type=type
}
Animal.prototype.speak=function(){
return`${this.type} is a type of animal .`
}
Array.prototype.aman=function(){
return`Custom made ${this}`
}
letmyArray=[1,2,3]
console.log(myArray.aman());
letmyNewArray=[1,2,3,4,5,6]
console.log(myNewArray.aman());
letanimal=newAnimal("Dog")
console.log(animal.speck)
classVehicle{
constructor(make,model){
this.make=make;
this.model=model;
}
start(){
return`${this.model} is a car from ${this.make}`
}
}
classcarextendsVehicle{
drive(){
return`${this.make} : This is an inheritance example .`
}
}
letmycar=newcar("Toyota","Collera")
console.log(mycar.start());
console.log(mycar.drive());