You are reading a single comment by @Gordon and its replies.
Click here to read the full conversation.
-
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.
Just coming to this afresh looking at just the first post (sorry if everyone else has already mentioned this), if you change:
to
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 (withstopWatch("auto")
) and then callingnew
on that. If it ever got to executingnew
it'd fail, but as it is it just runsstopWatch("auto")
and then throws an error becausethis
isn't astopWatch
object.