What is the difference between these?

so my question is that what is the difference between return and console.log , i already know that console.log directly log the value to the console and the return not , but for example in a function where no matter which one i use, until the time that i don’t invoke the function nothing happens but when i invoke it , both of them will log the value to the console (no matter if it is console.log or return) so when should i use which ?

Return does not log anything. Console.log logs the expression inside its parentheses. Console.log is mostly used for debugging and getting insight into what’s happening inside functions and at certain points in programs. Return is the thing you’ll actually end up using more often.

1 Like