You are reading a single comment by @Robin and its replies. Click here to read the full conversation.
  • This is about object reference.

    change this. to SOUND. in line 21.

    setInterval(function(){SOUND.beep(freq,t­ime); }, 1000);
    

    or add ‘that’

    
    function SOUND(pin,volume){
        this.PIN = pin;
        this.VOLUME = volume;
        var that = this;
    }
    
    SOUND.prototype.multibeep_works_not = function(freq,time,nr){
      setInterval(function(){ that.beep(freq,time); }, 1000);
    };
    
  • Sun 2020.01.26

    @MaBe, (haven't tested) but wouldn't var 'that' L5 need to be global in order for L9 to see object 'that'? . . . or maybe (guessing) SOUND.that.beep(?

    My belief was the (missing) argument syntax as shown in that link.

About

Avatar for Robin @Robin started