Javascript literal object and singleton pattern

Isn't an instance of a literal object in javascript a single?

Of course, there is no "self" component if the object is not found, but there is only one "copy" of the object that is around.

What do you think?

+3


source to share


1 answer


I found the answer in the article:

http://addyosmani.com/resources/essentialjsdesignpatterns/book/#singletonpatternjavascript



Singlets differ from static classes (or objects) in that we can delay their initialization, usually because they require some information that may not be available during initialization. They don't provide a way for code that doesn't know the previous link to them to get them easily. This is because it is neither an object nor a "class" returned by a Singleton, it is a structure. Think of how closed variables are not actually closed - the function scope that provides closure is closure.

+1


source







All Articles