Javascript Array Deferencing?

I have an array, say:


var pieces = [2008, 5, 19, 13, 49];

I’d like to create a date based on this; the equivalent of:


new Date( 2008, 5, 19, 13, 49 );

Is there a way to do that in Javascript? Can I dereference the array in my date create call? I’d prefer to avoid eval.

1 Comment so far

  1. Edward O'Connor on May 19th, 2008

    I think something like Date.apply(pieces) should DTRT. Untested of course.

Leave a Reply