Yeah you'll get the logging output, but that's not the same as the return value. The return value is always undefined unless a) an explicit return statement is used to return something other than undefined, or b) it's a single-statement arrow function with no enclosing block:
In the case of console.log, even if you return console.log('...'), the return value will still be undefined, because console.log itself returns undefined.
Sorry if I'm stating the obvious or my explanation is confusing.
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Yeah you'll get the logging output, but that's not the same as the return value. The return value is always
undefined
unless a) an explicitreturn
statement is used to return something other than undefined, or b) it's a single-statement arrow function with no enclosing block:In the case of
console.log
, even if youreturn console.log('...')
, the return value will still beundefined
, becauseconsole.log
itself returnsundefined
.Sorry if I'm stating the obvious or my explanation is confusing.