Thanks !!
Fantastic Suggestion !!

On Mon, Jan 23, 2012 at 7:35 PM, Diego Perini <[email protected]>wrote:

> Nice suggestion, it comes often handy and performance are surely better.
>
> It is possible to also use an "object" instead of an "array":
>
>    var a = ({ 0: false, 1: true })[index];
>
> this gives the same mapping with an "object" lookup instead.
>
> This let's you use both strings or numbers as indexes.
>
>
> Diego
>
>
> On Mon, Jan 23, 2012 at 1:33 PM, Narendra Sisodiya
> <[email protected]> wrote:
> > var a;
> > switch(num){
> >
> > case 0: a = false;
> > case 1: a = true;
> > }
> >
> > This whole process can be done via
> >
> > var a = [false,true][num];
> >
> > Like
> > var a = ["Mon","Tues","Wed","Thurs","Fri","Sat","Sun"][num] + "day";
> >
> >
> > --
> > ┌─────────────────────────┐
> > │    Narendra Sisodiya
> > │    http://narendrasisodiya.com
> > └─────────────────────────┘
> >
> > --
> > 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]
>
> --
> 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]
>



-- 
┌─────────────────────────┐
│    Narendra Sisodiya
│    http://narendrasisodiya.com
└─────────────────────────┘

-- 
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