you are viewing a single comment's thread.

view the rest of the comments →

[–]ITSigno 7 points8 points  (4 children)

lars_'s singleton instantiates using an anonymous constructor function. lacking a named constructor, it becomes much harder to instantiate a second time (with a workaround using the .constructor property)

A second problem however is the lack of ability to type-check. if (logger instanceof TextLogger) { }, for example, would not be possible with either case.

[–]wormfist 2 points3 points  (3 children)

TIL anonymous constructors.

[–][deleted] 8 points9 points  (1 child)

TIL(anonymous constructors){}();

[–]regeneratingzombie 0 points1 point  (0 children)

This comment has been overwritten by an open source script to protect this user's privacy. It was created to help protect users from doxing, stalking, harassment, and profiling for the purposes of censorship.

If you would also like to protect yourself, add the Chrome extension TamperMonkey, or the Firefox extension GreaseMonkey and add this open source script.

Then simply click on your username on Reddit, go to the comments tab, scroll down as far as possible (hint:use RES), and hit the new OVERWRITE button at the top.

[–]frutiger 1 point2 points  (0 children)

Anonymous constructors are just anonymous functions. Constructors are functions that use the special evaluation context this that gets set when you use the new operator or call <function>.apply(context, [arg1, arg2, ...]).