Let’s say I have this function in javascript:
function foo(a){
a.item = "four"
return a
}
b = {item:"three"}
b = foo(b)
console.log(b)
Since Javascript is a call-by-sharing language there is no need to return a
, the object b
would have the same final value with the below code:
function foo(a){
a.item = "four"
return a
}
b = {item:"three"}
foo(b)
console.log(b)
Is it bad practice to use return b
for better readability even though it is not needed
Are there any downsides to returning the object?