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
:
You can't expose a variable without exposing it. You should, however, be able to see the state of _legs while stepping through the constructor, addLeg and speed functions.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.