Is there any differences between the variables during the following strategies (de-structured versus part of body) of variable instantiation during function creation:
let obj = {z: {y: 99}}
let foo = ({z: {y}, x = `${y+1}`}) => console.log(x) //prints 100
let bar = (data) => {
let y = data.z.y;
let x = `${y+1}`;
console.log(x); //also prints 100
}
foo(obj);
bar(obj);
As far as I know both of these will create two variables, but I am wondering which is the superior approach in way of speed and memory.
Could not definitively conclude approach which completes in least amount of time. stacksnippets and
console
calls also appear to influence results.