Wemperer2 Posted November 11, 2014 Share Posted November 11, 2014 Why is it that if I create an array and put an object in it, then check the array's length, I get incriments of 15 for each object in the array instead of 1 per object? This is screwing me up because I'm not sure how to reference what I put in the array because I don't know where it is.var me = { name: 'bill',}var arr = [];arr += me; // one objectalert(arr.length); //15 objects in arrayalert(arr[0].name) //undefined Quote Link to comment Share on other sites More sharing options...
Samuel Girardin Posted November 11, 2014 Share Posted November 11, 2014 Hi, var me = { name: 'bill' } var arr = []; //var arr = []; arr[0] = me; // one object or arr.push(me) ; alert(arr.length); // 1 alert(arr[0].name) / bill Quote Link to comment Share on other sites More sharing options...
Wemperer2 Posted November 11, 2014 Author Share Posted November 11, 2014 Thank you!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.