(javascript) Calling a method on an object inside an array

Viewed 289

I am not sure i named the title properly. Let me explain my little problem.

My code snipppet is pretty short:

var myArray= new Array([new Date()],[123],[abc]);
var time = myArray[0].getTime()

I want the time saved in the object inside the array to be written to the "time" variable. I just thought this would work but i get an error.

Uncaught TypeError: myArray[0].getTime is not a function

Apparently i am doing it wrong, but i have no idea what is the problem and how to do it right.

3 Answers
Related