How to deconstruct objects like import * from moduleA?

-premise: module introduction can be done by means of import * from moduleA to introduce and declare all attributes under moduleA.

question: can js objects be deconstructed like this

write in this way

let obj = {
    a:1,
    b:2,
    c:3
}
let {*} = obj;  // 
console.log(a,b,c)
// :1 2 3

you can take out all the properties in the object and declare them.

//

let deconstruction = (obj) => {
//    ...
}

{
deconstruction(obj);
    console.log(a,b,c)
    // :1 2 3
}
console.log(a,b,c)
// :VM219:1 Uncaught ReferenceError: a is not defined

how to achieve such a function?

Mar.15,2022

if you insist on this, you can actually achieve

.
function test(o){
    for(let k in o){
        window[k] = o[k]
    }
}


let obj = {a:"1",b:"22",c:"3"}
test(obj)
console.log(a,b,c) // 1, 22, 3

but this is not recommended. A few more will make a mess


browsers do not support this way of writing, do you still ask how to achieve it? Write your own babel and compile the code?


I don't understand what you want to do, what you want to achieve is to make an object reference

let obj= {

x:1,
y:2

}

let a = obj
a.x / / 1
a.y//2

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37dc8-2b42f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37dc8-2b42f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?