I just encountered this weird problem. I don't remember I have it before but it has been quite a while since last time I develop any Chrome stuff.
The picture below pretty much speaks it by itself:
Why does Chrome console constantly return undefined for console.log
command? Any console.log
used in js scripts also return the same.
Update
console.log.toString()
returns "function log() { [native code] }"
If a function does not use a return statement or an empty return statement with no value, JavaScript automatically returns undefined. That means that in JavaScript every function returns something, at least undefined.
This is because console. log() does not return a value (i.e. returns undefined). The result of whatever you entered to the console is first printed to the console, then a bit later the message from console. log reaches the console and is printed as well.
The undefined property indicates that a variable has not been assigned a value, or not declared at all.
Return value: It returns the value of the parameter given. JavaScript codes to show the working of this function: Passing a number as an argument: If the number is passed to the function console.log() then the function will display it.
Are you filtering the messages by chance? Look in the upper right corner of the console to see if it says “1 hidden”.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With