I'm using the Google Chrome console. Frustratingly, the following code
var f = function () {};
f.a = 1;
console.log(f);
will only log
function () {}
Why does it not print the properties of f
, such as f.a
and f.prototype
? How can I print them?
dir() The method console. dir() displays an interactive list of the properties of the specified JavaScript object.
We can call any function inside a function, including console. log().
It's a function call. It goes to the call stack.
If you want to do this to an object that has been already logged (one time thing), chrome console offers a good solution. Hover over the printed object in the console, right click, then click on "Store as Global Variable". Chrome will assign it to a temporary var name for you which you can use in the console.
Try console.dir
.
console.dir(f);
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