(Sorry, this is slightly OT.)

var the_array = ["foo", "bar", "baz", "qux"];

//Is there a simpler way to do the following than what’s here?
var the_lookup = {};
the_array.forEach( function(i) { the_lookup.i = true } );

========

In Perl this is easy:
my @array = qw(foo bar baz qux);
my %lookup = map { $_ => 1 } @array;


Anything of the sort coming in JS, does anyone know? Maybe in some of the newer ES5 goodies?

-FG

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to