wongadob Posted May 22, 2012 Share Posted May 22, 2012 (edited) I have an object defined called feed. I have these two lines of code console.log (feed);console.log (feed['notifications']);var notes = feed.notifications.length-1; In Chrome debugger I am getting this - Object is feed [ Object meta: Array[0] notifications: Array[0] objects: Array[0] references: Array[0] __proto__: Object ] main.js:1714</p>undefined main.js:1715 Uncaught TypeError: Cannot read property 'length' of undefined Edited May 22, 2012 by wongadob Link to comment Share on other sites More sharing options...
wongadob Posted May 22, 2012 Author Share Posted May 22, 2012 I have tried using the combinations of .notifications and ['notifications'] I believe they are interchangeable, but I have tried all combinations and still I am getting this. It is really doing my head in as I cannot see anything wrong. Anybody know any reason why this might be happening Link to comment Share on other sites More sharing options...
wongadob Posted May 22, 2012 Author Share Posted May 22, 2012 (edited) BTW this is where the array/object is created. Note that NoteCache is passed to this function as feed var noteCache=new Array();noteCache.push({notifications: new Array(),references: new Array(),objects: new Array(),meta: new Array() }); Edited May 22, 2012 by wongadob Link to comment Share on other sites More sharing options...
justsomeguy Posted May 22, 2012 Share Posted May 22, 2012 If noteCache is feed, then you should be looking for feed[0].notifications. It looks like feed is an array with 1 item that is an object. Link to comment Share on other sites More sharing options...
wongadob Posted May 22, 2012 Author Share Posted May 22, 2012 Thanks Justsomeguy, I just figured that out a few mins ago the fact that it had a [0] index. Damn it that had me for hours! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now