• Mon 2018.10.08

    Thank you @MaBe for the working example:

    http://forum.espruino.com/conversations/­317394/#comment14111852


    Q1: While this.start() does work when testing a module as a monolithic file:

    constructor(option) {
            var timeStart = 0;
            var timeStop = 0;
            if( typeof option == "string" ) {
              if( option == "auto" )
                this.start();
    

    an error occurs when testing as a deployed module:

    >Uncaught Error: Function "start" not found!
     at line 5 col 18
                this.start();
    

    What is the correct syntax to reference an internal class method from inside that class?

    Indicates Class Definition 1v96 Official using 1v99

    http://www.espruino.com/Features



    Q2: An error occurs when using a multi-parameter constructor when a default constructor is present

    constructor() {
    
        // If option == "auto" auto start
          constructor(option) {
    

    ERROR: [notify_error] Input_0:14: ERROR - Class contains duplicate method name "constructor" in moduleTestConstructor

    Is the preferred method to use just the multi-parameter version and have implied optional arguments and code the single constructor for those options?

    e.g.
    if( typeof option == "undefined" ) {
    if( option != "undefined" ) {


    3 Attachments

About

Avatar for Robin @Robin started