Lasse Reichstein:
> On Thu, Oct 6, 2011 at 2:17 PM, Fyodorov &quot;bga&quot; Alexander <
> [email protected]> wrote:
>
> >
> > 1) convert your code to
> > {
> >  const singletonObject = (function(){
> >    // helper fns
> >
> >    return  {
> >      // privare members
> >      newsItems_: [],
> >
> >      _init: function(){
> >        // your object init here
> >        delete this._init // prevent double init
> >
>
> I recommend against using delete in objects that are not used as
> dictionaries. In modern Javascript engines, this might throw off the "hidden
> class" optimizations for the object and make it it slower
>
> Just have the init function next to the object and call it as:
>   return init.call({...my object literal...});
> for the same effect - or just inline the code in the anonymous function
> instead of introducing an extra initialization function. After all, the
> anonymous function's job is to create that object.
>
>        return  this
> >      },
> >
> >      // methods
> >      getFilters: function(){
> >
> >      }
> >    }._init()
> >  })()
> > }
> >
>
> ...
>
>
> > 5) you can forget about semicolon
> >
>
> No, please don't. It doesn't make code more readable, and it can make
> introduce subtle bugs if you don't know when semicolon is needed.
>
> /L

reason why many js coders still use ; is because they use other old
langs such as c++/java. New langs such as Go and Scala dont requires ;
because in most cases \n is ;. Imho ; is history of programming langs.
ASI rules is so simple. Just dont write {return\n}, {throw\n} and
{_foo()\n()} but who really write this code? Its abnormal code. Since
i use only modern langs i can forget about ; completely, its just
syntax noise and force me type more. I type ; only one line lambdas to
have explicit separator for my eyes. If i need write on some old lang
- i can  make small script which emulate ASI for this lang.

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to