I have lots of details. I want to stack them within an array, can I do that?
detailObj = {
textDetail: "hello this is my text!",
id: "tooltip_businessDetails"
};
var idArray[0] = detailObg;
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.
Yes:
Or if you already have variables pointing at them:
You can also do it dynamically after array creation:
And you can do it the way you tried to, just with a slight change:
Any time you set an array element, the array’s
lengthproperty is updated to be one greater than the element you set if it isn’t already (so if you setidArray[2],lengthbecomes3).Note that JavaScript arrays are sparse, so you can assign to
idArray[52]without creating entries for0through51. In fact, JavaScript arrays aren’t really arrays at all.