clean-code-javascript
clean-code-javascript copied to clipboard
pass by value is already default behavior of functions
Destructuring also clones the specified primitive values of the argument object passed into the function. This can help prevent side effects. Note: objects and arrays that are destructured from the argument object are NOT cloned.
Primitive arguments of functions are already cloned. This is not es6 object deconstruction specific behavior.
let a = 5;
const increment = (num)=> ++num;
console.log(increment(a));
console.log(a);
If the function accepts an object as a parameter, just the reference will be cloned.