Let's say we have data object someDescriptiveName and we need to destructure it multiple times in different functions with the purpose of being able to use shorter property names.
property1 Instead of this.someDescriptiveName.property1
someDescriptiveName: {
property1: false,
property2: false,
property3: false,
property4: false,
property5: false,
}
function func1() {
let {
property1,
property2,
property3,
property4,
property5,
} = this.someDescriptiveName
console.log(property1)
}
function func2() {
let {
property1,
property2,
property3,
property4,
property5,
} = this.someDescriptiveName
console.log(property1)
}
function func1() {
let {*} = this.someDescriptiveName
console.log(property1)
}
function func2() {
let {*} = this.someDescriptiveName
console.log(property1)
}
Thanks for the feature suggestion! Please see https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md#creating-a-new-proposal for how to best suggest new features to the language (also, the "feature request" issue template you modified to post this issue).
@AlexSHoffman This exists: it鈥檚 the with statement. It鈥檚 disallowed in strict mode because it leads to a variety of problems.
@bathos thanks for letting me know about this
Most helpful comment
@AlexSHoffman This exists: it鈥檚 the
withstatement. It鈥檚 disallowed in strict mode because it leads to a variety of problems.