Static & Private Class Fields
What pattern is implemented using private members?
class Connection {
#config;
#retryCount = 0;
static #MAX_RETRIES = 3;
constructor(config) {
this.#config = config;
}
async #connect() {
while (this.#retryCount < Connection.#MAX_RETRIES) {
try {
// Connection logic
return;
} catch (e) {
this.#retryCount++;
await new Promise(r => setTimeout(r, 1000 * this.#retryCount));
}
}
throw new Error('Connection failed');
}
}