As a developer in C#, I am shifting to learning JavaScript. Here is a piece of code in C#:
public string Name { get; set; }
How would I transform this code(getters/setters) to JavaScript?
#name = "initial";
get name() { return this.#name; };
set name(value) { this.#name = value; };
That would be the closest Javascript, using private class properties and class getter / setters .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.