I have the following config javascript, where i can hardcode the selectors divs etc and set few attributes so it can be invoked by other functions to provide the needed values. I don't want to create seperate instance everytime i invoke ex. config = new Config() which is not good. So i have changed the code in the form of javascript closures, is that will have only one instance no matter how many times it is created?
Config = function() {
/**
* Ids to external objects.
* @public
* @type object
*/
this.ids = {
objec1: "whiteboard",
text1: "dialogInputText",
image1: "dialogInputImage",
icons: "dialogIcons",
size: "dialogResize"
};
/**
* Paper Type
* @public
* @type property
*/
this.types = {
store: "TSC",
document: "Document"
}
}
Convert to closure
Config = (function(){
result = { /**
* Ids to external objects.
* @public
* @type object
*/
ids: {
objec1: "whiteboard",
text1: "dialogInputText",
image1: "dialogInputImage",
icons: "dialogIcons",
size: "dialogResize"
},
/**
* Paper Type
* @public
* @type property
*/
types: {
store: "TSC",
document: "Document"
}
})()