I need some help with return and destructure an object from a function. I want to assign new paras to what ever return from the function.
function someRes() {
const val1 = 1
const val2 = 2
return {val1, val2}
}
const {val1, val2} = someRes()
const {val3, val4} = someRes()//this returns as undefined
console.log(val1, val2)
console.log(val3, val4) //console.log undefined
I understand that destructure a params is not like assign them to new params but still, Im looking for an elegant way to do it.
thank!