+ 1
Why i get undefined output in the node.js terminal?
Working on new node.js. Code: Var a='oops'; Console.log(console.log(a)); Output: Oops Undefined ....................... WHY
1 Antwort
+ 1
`console.log` does not return anything.
https://developer.mozilla.org/en/docs/Web/API/Console/log
When you nest method calls like that, the inner most call is evaluated first, in this case `console.log(a)`, as a statement, be executed, which outputs value of <a> in the JS console.
The outer call to `console.log` expected something from its argument. BUT, since nothing was explicitly returned by the inner `console.log` call, the outer `console.log` call gets `undefined`