• I do not have much experience with JavaScript (have quite a bit with Java).
    It is weird issue from my perspective. If I assign an object's method call to event, it runs in empty object instance. All fields are empty. But if I wrap object's method into a function, and put into event, it runs ok. Is it normal?
    Example:

    const O = {
      A:"", B:0,
      M : function(){
        this.A = this.A + "*";
        this.B = this.B + 1;
        print(this.A," - ", this.B);
      }
    };
    
    function F(){
      O.M();
    }
    
    // uncomment one  or another call and run
    //setInterval(O.M, 1000); // method M runs in empty object instance
    //setInterval(F, 1000); // method M runs in populated object instance
    

    Output of direct method assignment

    undefined*  -  NaN
    undefined**  -  NaN
    undefined***  -  NaN
    

    Output of wrapped method assignment

    *  -  1
    **  -  2
    ***  -  3
    
About

Avatar for Mark_M @Mark_M started