Coggle requires JavaScript to display documents.
class User { constructor(fName, lName) { this.firstName = fName; this.lastName = lName; } fullName = function () { return this.firstName + " " + this.lastName; }; } let user1 = new User('Renay', 'Earnshaw') let user2 = new User('Philip', 'Earnshaw')
class User { ... fullName() { return this.firstName + " " + this.lastName; }; }
class User { state = 'happy'; <- class field constructor(fName, lName) { this.firstName = fName; this.lastName = lName; } ... }
undefined
class User { state = "happy"; #firstName; #lastName; constructor(fName, lName) { this.#firstName = fName; this.#lastName = lName; ... } console.log(user1.#firstName)
Property '#firstName' is not accessible outside class 'User' because it has a private identifier