Internally, in the first example, the JS engine looks like this:
function func1() { return; array.map(function(el){ return el.method(); }); };
why do you get undefined , do not add a new line after return , because the return statement, followed by a new line, tells JS-intepreter that after that return half a ton should be inserted.
function func1() { return array.map(function(el){ return el.method(); }); };
source share