2

I have been reading a bit about undefined and just started wondering that we see undefined when we declare a function in browser console.

Does calling a function always return a value? If we do not explicitly return a value, then by default undefined value is returned from a function.

That is to say, a function will always return a value. Always. Is that correct?

var aFunc = function(){
 console.log( "aFunc ran." );
}
aFunc() === undefined // true
Kayote
  • 12,599
  • 17
  • 72
  • 133

1 Answers1

3

Yes it always returns a value, if explicit one is not given, it returns undefined. This is same as you will write return undefined or just return.

Suren Srapyan
  • 62,337
  • 13
  • 111
  • 105