static variables

boolean, counter

JavaScript

// not 'this',...
// reference:
// http://stackoverflow.com/questions/7307243/how-to-declare-a-static-variable-in-javascript
debugger;

function toggleLamp() {
    toggleLamp.count = ++ toggleLamp.count || 1;

    toggleLamp.state = toggleLamp.state == undefined ? false : ! (toggleLamp.state);
    console.log (toggleLamp.state);
}

toggleLamp();
toggleLamp();
toggleLamp();
toggleLamp();