Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This code snippet is used in ES6 Classes JavaScript Tutorial on SFDC Stop
class Car {
#color
constructor(name, speed, color) {
this.name = name;
this.speed = speed;
this.#color = color;
}
showSpeed() {
console.log(this.speed);
}
showColor() {
console.log(this.#color);
}
}
let audi = new Car('audi', 300, 'red');
audi.showSpeed();
console.log(audi.name);
console.log(audi.speed);
// console.log(audi.#color);
audi.showColor();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment