• Just coming to this afresh looking at just the first post (sorry if everyone else has already mentioned this), if you change:

    stopWatch = new require('moduleTestConstructor')("auto")­)();
    

    to

    stopWatch = new (require('moduleTestConstructor'))("auto­");
    

    It works great.

    Also, if you take your all-in-one file that works and change stopWatch = new stopWatch("auto"); to the equivalent of what you've done in the other example: stopWatch = new (stopWatch("auto"))(); then it breaks in exactly the same way.

    What you're doing is running the stopWatch constructor as a bare function (with stopWatch("auto")) and then calling new on that. If it ever got to executing new it'd fail, but as it is it just runs stopWatch("auto") and then throws an error because this isn't a stopWatch object.

  • Tue 2018.10.09

    Ref #15 Short and precise along with the paragraph explanation. That is what I was after. Thank you @Gordon.

    Placing the '()' and the argument correctly gave me fits, even with the IIFE construct present in the original source.

    I'm researching 'bare functions' as I've not heard that term before.

About

Avatar for Gordon @Gordon started