Understanding custom events...

Understanding custom events...

I can understand the example below well, except: in the last click function, there is a .length property attached to `$(''.lightbulb.on')`. Im not sure how the .length property is working here. If someone could explain this for someone who is still very new to jQuery and javascript. Thanks.
      
 `$('.lightbulb').on('changeState',function(e){
        var light=$(this);
        if(light.hasClass('on')){
            light.trigger('turnOff');
        }else{
            light.trigger('turnOn')
        }
    }).on('turnOn',function(){
        $(this).removeClass('off').addClass('on');
    }).on('turnOff',function(){
        $(this).removeClass('on').addClass('off');
    });
    $('.switch , .clapper').click(function(){
        $(this).parent().find('.lightbulb').trigger('changeState');
    });
    $('#master_switch').click(function(){
        if( $('.lightbulb.on').length ) {
            $('.lightbulb').trigger('turnOff');
        }else{
            $('.lightbulb').trigger('turnOn');
        }
    });`