1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
const g = []; class G { #g; constructor(shared){ if (shared) { this.#g = g; } else { this.#g = []; } } } const g1 = []; class H { #g; constructor(shared1){ if (shared1) { this.#g = g1; } else { this.#g = []; } } } console.log(new G(true), new H(true));