You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Thanks! This looks great - just merged and should go live in the next day or so. I wouldn't worry about the pretokenisation - I'm not actually sure why it'd be giving you any problems, but it might be combination of that and minification.

    after I converted the arrow functions into the old ES5 syntax, things are working again

    Yeah, this is actually a common thing with arrow functions. They store this from when they are defined (and it overwrites the current this). Yet another fantastic JS design decision that can trip you up!

    var outer = {
      data : "oops.",
      go : function() {
        return {
          data : "Yay!",
          arrow : () => console.log(this.data),
          normal : function() { console.log(this.data); }
        };
      }
    };
    var a = outer.go();
    
    a.arrow();
    //oops.
    a.normal();
    //Yay!
    

    (Having said that I did notice a bug in Espruino's arrow function implementation which I'll have to get fixed)

About

Avatar for Gordon @Gordon started