All javascript methods have a return value??? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

All javascript methods have a return value???

5th Sep 2021, 1:26 PM
Aniket Ganguly
4 Answers
+ 3
Every function in JavaScript is a Function object. A function without a return statement will return a default value. In the case of a constructor called with the new keyword, the default value is the value of its this parameter. For all other functions, the default return value is undefined .
5th Sep 2021, 3:10 PM
SAN
SAN - avatar
+ 1
of course. undefined even if you don't use "return" word
5th Sep 2021, 1:55 PM
David Ordás
David Ordás - avatar
+ 1
SAN I think is better with sample code function awesome() {} var obj = new awesome(); var a = awesome(); "obj" has value, an instance of awesome (internally this) "a" value is undefined.
6th Sep 2021, 6:24 PM
David Ordás
David Ordás - avatar