Difference between console.log and return

You’ve read the title and know it. I cannot see much of a difference

Maybe an example can help:

function logFun(){
    console.log('I log stuff')

function returnFun(){
    return 'I return stuff'

const test1 = logFun();
const test2 = returnFun();

After this,

  • test1 will be undefined
  • test2 will be 'I return stuff'
1 Like