var foo = {}
var bar = new Array();
var another = [];
Also, is it possible to add to foo like so:
foo['obj'] = new Date();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
foois an object literal.baris an array initialized via theArrayconstructor.anotheris an array literal. Creating new arrays through literals is more efficient than doing so through theArrayconstructor: http://jsperf.com/new-array And it’s also much easier to type 😉 I’d recommend using array literals wherever possible.Yes. That will add a property
objtofoowith the value ofnew Date(). It’s equivalent tofoo.obj = new Date();.