Skip to main content
Tweeted twitter.com/#!/StackCodeReview/status/173688435406684160
improved formatting
Source Link
palacsint
  • 30.4k
  • 9
  • 82
  • 157

Diving deeper in Javascript. Need some advice JavaScript singleton with methods and properties

I am diving deeper into javascriptJavaScript and starting to learn more about prototypes and simulating Classesclasses etc. I am used to working with the Module pattern and would like to try and combine this pattern along with working with prototyping into aan own little framework  (Purelypurely for learning purposes).

I have devised a little contructconstruct and i whasI was hoping if some of you advanced users could give me some feedback on the particular construct.

What iI am trying to achieve is to create a singleton with methods and properties one could access, iI would like to extend/build this via the prototype as speed is something iI care alota lot about. The thing iI still have doubts about is whether or not this would be a suitable construct for what iI have in mind, whether or not this would be fast etc.

Much appreciated! Here's the code.

var Mui = (function (window, document, undefined) {

Mui = function () {
    this.Version = {
        Major  : '0',
        Minor  : '1',
        Bugfix : '0'
    };
};

Mui.prototype = {
    sayHi : function () {
        alert('hi');
    }
};

return new Mui;

}(window, this.document));

Diving deeper in Javascript. Need some advice

I am diving deeper into javascript and starting to learn more about prototypes and simulating Classes etc. I am used to working with the Module pattern and would like to try and combine this pattern along with working with prototyping into a own little framework(Purely for learning purposes).

I have devised a little contruct and i whas hoping if some of you advanced users could give me some feedback on the particular construct.

What i am trying to achieve is to create a singleton with methods and properties one could access, i would like to extend/build this via the prototype as speed is something i care alot about. The thing i still have doubts about is whether or not this would be a suitable construct for what i have in mind, whether or not this would be fast etc.

Much appreciated! Here's the code.

var Mui = (function (window, document, undefined) {

Mui = function () {
    this.Version = {
        Major  : '0',
        Minor  : '1',
        Bugfix : '0'
    };
};

Mui.prototype = {
    sayHi : function () {
        alert('hi');
    }
};

return new Mui;

}(window, this.document));

JavaScript singleton with methods and properties

I am diving deeper into JavaScript and starting to learn more about prototypes and simulating classes etc. I am used to working with the Module pattern and would like to try and combine this pattern along with working with prototyping into an own little framework  (purely for learning purposes).

I have devised a little construct and I was hoping if some of you advanced users could give me some feedback on the particular construct.

What I am trying to achieve is to create a singleton with methods and properties one could access, I would like to extend/build this via the prototype as speed is something I care a lot about. The thing I still have doubts about is whether or not this would be a suitable construct for what I have in mind, whether or not this would be fast etc.

Much appreciated! Here's the code.

var Mui = (function (window, document, undefined) {

Mui = function () {
    this.Version = {
        Major  : '0',
        Minor  : '1',
        Bugfix : '0'
    };
};

Mui.prototype = {
    sayHi : function () {
        alert('hi');
    }
};

return new Mui;

}(window, this.document));
Source Link
ngr
  • 115
  • 9

Diving deeper in Javascript. Need some advice

I am diving deeper into javascript and starting to learn more about prototypes and simulating Classes etc. I am used to working with the Module pattern and would like to try and combine this pattern along with working with prototyping into a own little framework(Purely for learning purposes).

I have devised a little contruct and i whas hoping if some of you advanced users could give me some feedback on the particular construct.

What i am trying to achieve is to create a singleton with methods and properties one could access, i would like to extend/build this via the prototype as speed is something i care alot about. The thing i still have doubts about is whether or not this would be a suitable construct for what i have in mind, whether or not this would be fast etc.

Much appreciated! Here's the code.

var Mui = (function (window, document, undefined) {

Mui = function () {
    this.Version = {
        Major  : '0',
        Minor  : '1',
        Bugfix : '0'
    };
};

Mui.prototype = {
    sayHi : function () {
        alert('hi');
    }
};

return new Mui;

}(window, this.document));