When a function in javaScript has no return value, the function returns undefined by default
Look at the following code:
//函数有返回值
function fn1(){
var hometown = '江西省赣州市于都县';
return hometown; //有返回值
}
var a = fn1();
console.log('fn1()函数的返回值=' + a);
//函数无返回值
function fn2(){
var hometown = '赣州市于都县';
无返回值
}
var b = fn2();
console.log('fn2()函数的返回值=' + b);
The results of the operation are as follows: