Posts

Showing posts from December, 2016

JavaScript module pattern and "new" keyword

It is an old post based on old idea, it is not so relevant anymore.   I have just encountered an article about JavaScript module pattern. As a Java developer, it blows my thinking about JavaScript. So far, it is the excellent article about JavaScript module pattern, according to my point of view. I added the link of the article for me and who wants to learn module pattern. https://toddmotto.com/mastering-the-module-pattern/ However, the self invoked function creates only one object in the memory. As a Java developer, it looks like Java singleton or static method kind of thing. You cannot create multiple objects using self invoked function. In this post, I am trying to demonstrate the situation step by step using simple example and potential solution of this issue.  For example: var Name = (function(){ var firstName = "Ted"; var lastName = "Bid"; var nameObject = {}; nameObject.setFirstName = function(fn){ ...