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 <naren...@narendrasisodiya.com> 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/jsmentors@jsmentors.com/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/jsmentors@googlegroups.com/ > > To unsubscribe from this group, send email to > jsmentors+unsubscr...@googlegroups.com -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com