private-fields.js (451B)
1 class MyClass { 2 constructor(secret, ...rest) { 3 const self = this; 4 this.#secret = secret; 5 self.#restParams = rest; 6 } 7 8 #secret; 9 #restParams; 10 #salt = "bloup"; 11 creationDate = new Date(); 12 13 #getSalt() { 14 return this.#salt; 15 } 16 17 debug() { 18 const self = this; 19 const creationDate = this.creationDate; 20 const secret = this.#secret; 21 const salt = self.#getSalt(); 22 return `${creationDate}|${salt}|${secret}`; 23 } 24 }