while I was going through concepts related to JavaScript functions, I came up with problem which I'm unable to figure it out. I use following codes i.e one with return as a function and the other as a simple function as follows
function plus(a, b) {
return(
console.log(a+b),
console.log(this),
console.log(arguments)
)
}
plus(4,5);
and
function plus(a, b) {
console.log(a+b),
console.log(this),
console.log(arguments)
}
plus(4,5)
But when I run both I'm not able to figure it out since both results same in console. So I just want to know when should I use return as function.? and what is its main purpose? I've seen answers here but those related to return entire function or objects but didn't find specific answer to return as a function. So please help me in it.
undefinedin both cases.return"as a function" not "return a function", by which the OP must mean callingreturnwith a()enclosed list of statements.console.log(a+b, this, arguments), noreturn