基本的にここで私が達成しようとしていることがあります。JavaScriptのクラスプロパティにオブジェクトを広げる方法
class Person {
constructor (obj) {
this.first = ''
this.last = ''
this.age = ''
if (obj) {
Object.assign(this, ...obj)
}
}
}
const a = new Person()
console.log('Not spreading: ', a)
const b = new Person({ first: 'Alex', last: 'Cory', age: 27 })
console.log('Spreading: ', b)
クラスを移入するために、このようなオブジェクトを普及させる方法はあり ?
私は –
@AlexCoryすごい...今ダム感じる:LOL、我々はすべてのそのようなことをやりました。 :-) –