tc39 / proposal-class-fields

Orthogonally-informed combination of public and private fields proposals
https://arai-a.github.io/ecma262-compare/?pr=1668
1.72k stars 113 forks source link

Constructor arguments with object destructuring #334

Closed dfdgsdfg closed 2 years ago

dfdgsdfg commented 2 years ago

Is there any natural way or practice to use fields for refactoring constructor arguments with object destructuring?

I mean, not kind of tricky way.

legacy code

class Animal {
  constructor({name, age}) {
    this.name = name
    this.age = age
  }
}
dfdgsdfg commented 2 years ago

Oh.. It's my mistake. I have to bind it in constructor.

Thanks. : )