在下面的类中,对于构造函数,使用的参数是
{机柜=‘云杉’,失真= '1',体积= '0‘}= {}
class GuitarAmp {
constructor ({ cabinet = 'spruce', distortion = '1', volume = '0' } = {}) {
Object.assign(this, {
cabinet, distortion, volume
});
}
}通常情况下,参数被传递给构造函数,我不明白为什么这里会有一个赋值。
从这里获取代码
https://stackoverflow.com/questions/56677903
复制相似问题