Access Modifiers
class Car {
constructor(name) {
this.name = name;
}
static hello(x) {
return "Hello " + x.name;
}
}
let myCar = new Car("Toyota");
console.log(Car.hello(myCar)); // Hello Toyotaclass Car {
constructor(name) {
this.name = name;
}
static hello(x) {
return "Hello " + x.name;
}
#present(carname) {
return 'I have a ' + this.carname;
}
}
let myCar = new Car("Toyota");
console.log(myCar.#present("Camry")); // Error
console.log(Car.hello(myCar)); // Hello ToyotaLast updated