• what is wrong with my sample code - any comments ?

    online with WEB IDE

    var bla = {
      init : function() {
        console.log("bla.init");
        this.foo();
        this.bar();
      },
      foo : function() {
        console.log("bla.foo");
      },
      bar : function() {
        console.log("bla.bar");
      }
    }
    
    > bla.init();
    
    /* output 
    
    bla.init
    bla.foo
    bla.bar
    
    */
    
    

    with E.on(): Uncaught Error.....

    var bla = {
      init : function() {
        console.log("bla.init");
        this.foo();
        this.bar();
      },
      foo : function() {
        console.log("bla.foo");
      },
      bar : function() {
        console.log("bla.bar");
      }
    }
    
    E.on("init",bla.init)
    
    setTimeout(save,2000);
    
    
    /* output
    
    bla.init
    Uncaught Error: Function "foo" not found!
     at line 2 col 10
        this.foo();
             ^
    in function called from system
    
    */
    
About

Avatar for MaBe @MaBe started