javascript thing

I can’t find the bookmark to the original source for this on my home computer, and anyway the bookmark that I thought worked on my work computer seems to be out of date.  So, here is the shell of how I start javascript programs.  Your mileage may vary.

// closure to hide the prototype
var MyObject = (function(){
    /* private static (class) members */

    /* private static methods. */

    /*class constructor.*/
    function constructorFn(id){ = id;
        var self = this;
        /* call private static (class)  methods, etc */

        /* privileged instance methods. */


    /* privileged static (class) methods   (a property of the constructor) */
    //constructorFn.getNoOfInsts = function(){
    //    return counter;

    /* public instance method privaliged at the  class level */
    //constructorFn.prototype.pubInstMethod = function(){
    //   ...

    /*return the constructor.*/
    return constructorFn;
})(); //simultaneously define and call (one-off)!

/* public static  members */
// MyObject.pubStatic = "anything"

I even tried searching for that characteristic “define and call (one-off)” line that I know was in the original source, but the original didn’t turn up.

Ah, found this link, and clicking on the link in that page turns up a dead end.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.