Console dev tools

whats the difference between

console.log();
and
console.dir();
which one to use?

and i tried accessing my method in my object

var pizza = {

howmanyToppings:function(){
return this.toppings; }
};
console.log(pizza.howmanyToppings());
console.log(pizza.howmanyToppings);

with both of them different thigs happen in the console
with this one
console.log(pizza.howmanyToppings());

i get value from the return.this toppings;
and with the 2nd one i just get
this in my console

return this.toppings; }```

This page may help. A quick check to see the difference yourself is to type the following into your console and note the differences.

console.log([1, 2]);
console.dir([1, 2]);

In terms of the functions and parentheses, without the parentheses (when you type console.log(pizza.howmanyToppings), the console will output the function definition itself, which you have noted. Adding the parentheses actually evaluates the function, which is why you get an actual value.

I hope that helps.

1 Like