Why i get undefined output in the node.js terminal? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 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

9th Mar 2020, 2:23 AM
SHAIK MOHAMMAD ARSHAD
SHAIK MOHAMMAD ARSHAD - avatar
1 Réponse
+ 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`
9th Mar 2020, 5:22 AM
Ipang