Say you have 2 identical functions that do not return a value
function a() {
// do some interesting things
}
function b() {
// do the same interesting things
return;
}
Function b is obviously more verbose but is there any functional difference between these?
There’s no real difference; both will return
undefined.Functions with no return statement will return
undefined, as will functions with an emptyreturnstatement.To confirm this for yourself, you can run this code — FIDDLE: