• Thank you myownself and Gordon! Will know.

    setInterval(() => O.M(), 1000) - looks cool
    
  • Mark_M

    this is an alternative of 'wrapping' - .bind() :

    const O = {
      a:"", b:0,
      m : function(){
        this.a = this.a + "*";
        this.b = this.b + 1;
        print(this.a," - ", this.b);
      }
    };
    var O_M = O.m.bind(O); // binding O as context for 'this' in function / method m
                          // returns a new function with the right context set of this for O.
    
    setInterval(O_M,1000);
    

    For Function.prototype.bind() see https://developer.mozilla.org/en-US/docs­/Web/JavaScript/Reference/Global_objects­/Function/bind (and take also a look at the referenced .apply(...) ).

    Btw, in JS same upper/lower/camel-casing as Java is useful. Constructor functions - like Classes in Java (and other 'like-minded' languages) - have an uppercase initial.

About

Avatar for allObjects @allObjects started