I can return object from function in two ways:
Way 1:
function f() {
const obj = {
a: 1,
state: true
}
return obj
}
Way 2:
function f() {
const obj = {
a: 1,
state: true
}
return {...obj}
}
What is the right way to do it from point of view memory consumption? What is the best practice?