Coming from Python, learning JavaScript:
var test = 1;
var test2 = function(arg) {console.log(arg);};
When I execute var test3 = test2(test); in console, I get as a response:
undefined
1
But when I re-enter test3 or console.log(test3) I'm getting the undefined response inestead of 1. I tried to return value in function instead:
var test2 = function(arg) {return(console.log(arg));};
and
var test2 = function(arg) { var text = console.log(arg); return text;};
But I'm still getting the same response. How to 'bind' result of the function test2 to variable test3?
Thanks.
undefined, and that goes forconsole.log()as well.return. For example:function(arg) {console.log(arg); return arg;}