2022-02-04 11:08:38 +03:00
|
|
|
// @target: esnext, es2022, es2015
|
2021-01-15 13:30:44 +03:00
|
|
|
|
|
|
|
class A {
|
|
|
|
#a = 'a';
|
|
|
|
#b: string;
|
|
|
|
|
|
|
|
readonly #c = 'c';
|
|
|
|
readonly #d: string;
|
|
|
|
|
|
|
|
#e = '';
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
this.#b = 'b';
|
|
|
|
this.#d = 'd';
|
|
|
|
}
|
|
|
|
|
|
|
|
test() {
|
|
|
|
const data: Record<string, string> = { a: 'a', b: 'b', c: 'c', d: 'd', e: 'e' };
|
|
|
|
const {
|
|
|
|
[this.#a]: a,
|
|
|
|
[this.#b]: b,
|
|
|
|
[this.#c]: c,
|
|
|
|
[this.#d]: d,
|
|
|
|
[this.#e = 'e']: e,
|
|
|
|
} = data;
|
|
|
|
console.log(a, b, c, d, e);
|
|
|
|
|
|
|
|
const a1 = data[this.#a];
|
|
|
|
const b1 = data[this.#b];
|
|
|
|
const c1 = data[this.#c];
|
|
|
|
const d1 = data[this.#d];
|
|
|
|
const e1 = data[this.#e];
|
|
|
|
console.log(a1, b1, c1, d1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
new A().test();
|
|
|
|
|