4
我用解構宣佈一些像這樣的變量:解構與嵌套對象和默認值
const { a, b, c } = require('./something'),
{ e = 'default', f = 'default'} = c;
有沒有一種方法,使之成爲一條線嗎? 我已經試過類似:
const { a, b, c = { e = 'default', f = 'default'} } = require('./something');
但它給我一個錯誤:
SyntaxError: Invalid shorthand property initializer