3

オブジェクト破壊割り当てで予約済みキーワードを使用することは可能ですか?

具体的には、default という名前のプロパティ プロパティで JSON を処理しようとしています。

//Doesn't compile
class FooBar {
  constructor({foo, default}) {
    this.foo = foo;
    this.default = default;
  }
}


/* json from server {foo: "bar", default: true} */
new FooBar(json);
4

1 に答える 1