Why the result of printing x
using console.log
is undefined
?
Update:
This is not a duplicate. I'm trying to understand why console.log doesn't print.
Why the result of printing x
using console.log
is undefined
?
This is not a duplicate. I'm trying to understand why console.log doesn't print.
console.log
.So I dig a little bit and I found something that could of happen to you.
when you open your Dev Tools, you have this little icon on the left:
if you clicked on it, it will open a sidebar and if you are marking one of the two options that I point, it will not show the console.log print.
Change to the first selection, and you'll find out that you get the print.
Logging to the console is a redundant action in devtools, since it is bound to output to the console any values that are passed to it.
x
Is the proper way to print the value of x to the console.
console.log(x)
Is basically the same as writing
console.log(console.log(x))
Which returns undefined. Though, if you have an active debugger, it will evaluate and also print the value
I found an answer here: Chrome: console.log, console.debug are not working:
By @Tim:
Same issue, but I just cleared my settings. I went into Settings > Preferences and Clicked [Restore defaults and reload]. Just remember what your settings were.