I have this code snippet that scientifically accurate calculates the speed of a cat according to the amount of legs it has.
function Cat()
{
var self = this;
var _legs = 0;
self.addLeg = function()
{
_legs++;
}
self.speed = function()
{
return Math.pow(_legs,1.5)*2;
}
}
Chrome Debugger
When I try to debug one of my cats, how can I see the inner variables, like _legs
:
- without adding extra code just to expose it,
- nor 'actively' executing functions in the cat (that might change state)?