tag:blogger.com,1999:blog-8421903615286376978.post2301898385599973472..comments2023-10-29T11:23:42.372+00:00Comments on Web Interface Development: My JavaScript patternsJames Nortonhttp://www.blogger.com/profile/04054375264545036477noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-8421903615286376978.post-58055980716435216342009-05-06T17:42:00.000+01:002009-05-06T17:42:00.000+01:00I don't really comment on using the prototype in t...I don't really comment on using the prototype in this example of a constructor. I definitely think the prototype should be used whenever it is sensible to do so as there is a performance gain. However, if few instances created and used and there are few functions on the object, then it becomes less of a concern. As in all things, use the correct tool at the correct time!James Nortonhttps://www.blogger.com/profile/04054375264545036477noreply@blogger.comtag:blogger.com,1999:blog-8421903615286376978.post-62796650968607437532009-05-06T17:33:00.000+01:002009-05-06T17:33:00.000+01:00What do you think about the performance of recreat...What do you think about the performance of recreating these methods on every object instance, rather than one time on their prototype? This is mainly why I have avoided the constructor function pattern you describe, despite its advantages.alxdarkhttps://www.blogger.com/profile/07624154708867929885noreply@blogger.comtag:blogger.com,1999:blog-8421903615286376978.post-79240020214884132362008-11-14T20:16:00.000+00:002008-11-14T20:16:00.000+00:00Hi James, I have been looking all over the interne...Hi James, I have been looking all over the internet as to why there are brackets around the singleton anonomous constructor function. :(Adam Silverhttps://www.blogger.com/profile/04964892106482638246noreply@blogger.comtag:blogger.com,1999:blog-8421903615286376978.post-1750328848288625142008-07-04T14:30:00.000+01:002008-07-04T14:30:00.000+01:00Both very good patterns. Personally though I pref...Both very good patterns. Personally though I prefer the other singleton pattern<BR/><BR/>var myObj = function(){<BR/> // private area<BR/><BR/> // public return object<BR/> return {<BR/> init:function(){<BR/> }<BR/> }<BR/>}<BR/><BR/>Feels much cleaner to me but that's just a personal opinionkouphaxhttps://www.blogger.com/profile/06807861387916239017noreply@blogger.comtag:blogger.com,1999:blog-8421903615286376978.post-6035348881560925232008-06-10T12:29:00.000+01:002008-06-10T12:29:00.000+01:00Very nice. I'm learning javascript and I've found ...Very nice. I'm learning javascript and I've found that javascript functions are extremely powerful. I've blogged about it myself. Also how did you highlight the syntax? Thanks.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-8421903615286376978.post-14631407865781381662008-06-10T09:15:00.000+01:002008-06-10T09:15:00.000+01:00Very very useful, I have started to use both of th...Very very useful, I have started to use both of these patterns and have found them to be very effective so far.<BR/><BR/>It is so simple yet powerful.Adam Silverhttps://www.blogger.com/profile/04964892106482638246noreply@blogger.com