Created
February 21, 2021 07:12
-
-
Save rahulmalhotra/aa8a7831deb52e06fc90067d945a5e61 to your computer and use it in GitHub Desktop.
This code snippet is used in ES6 Classes JavaScript Tutorial on SFDC Stop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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