DEV Community 👩‍💻👨‍💻

Discussion on: Classes in JS: Public, Private and Protected

shadowtime2000 profile image
shadowtime2000 • Edited on

For protected variables you could also kind of use what was used for private variables with a function.

function NameGenerator(name) {
var publicData = {name};
var privateData = publicData;
return {...publicData, john() {return NameGenerator("John")}};

Though I don't have any good idea on how to actually change the values instead of creating a new object;