You are reading a single comment by @allObjects and its replies. Click here to read the full conversation.
  • What about line 9 reading PengMod.prototype.a = function() { ...? Because the object (instance of PengMod 'class') created in line 12 will not understand method .a(). I know that there are 'tricks' to stick also properties to a function (constructor), but I'm not sure that you really want this... or do you?

    But in deed, in a 'regular' js environment it works as expected... @Gordon? ...I guess the context where Espruino tries to resolve the variable is in the function's properties rather than in the function body's scope, of which arguments is a part of... and arguments is messed up too...

    function PengMod(a) {
      console.log("arguments: ", arguments.length, arguments );
      console.log("var a: " + a );
    }
    PengMod.a = function () {
    };
    new PengMod( "hello" );  console.log("arguments: ", arguments.length, arguments );
    

    produces this console output:

     1v86 Copyright 2016 G.Williams
    >echo(0);
    arguments:  2 [
      function () {},
      "hello"
     ]
    var a: function () {}
    

    I hoped that at least arguments wasn't messed up... but may be these things are all very and intrinsicly intertwined...

About

Avatar for allObjects @allObjects started