Skip to content

Commit d15ff2f

Browse files
committed
Constructor
1 parent 3f35462 commit d15ff2f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

class_obj.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,20 @@ console.log(Student);
1616
console.log(Student.fieldName);
1717

1818
class Car {
19+
constructor(brand) {
20+
console.log("It's a Car Constructor...");
21+
this.brand = brand;
22+
}
1923
start() {
2024
console.log("Start");
2125
}
2226
stop() {
2327
console.log("Stop");
2428
}
25-
setBrand(brand) {
26-
this.brand = brand;
27-
}
2829
}
2930

30-
let porsche = new Car();
31-
porsche.setBrand("Porsche");
31+
let porsche = new Car("Porsche");
32+
// porsche.setBrand();
3233
porsche.start();
3334
porsche.stop();
3435
console.log(porsche);

0 commit comments

Comments
 (0)