views:

35

answers:

0

Good afternoon,

I ran into some issues storing data. Let's say I can make a note, which contains the content of the note, an ID, timestamp, all that good stuff. I want to store my notes in an associative array, called notes, via each note's ID. So in a method, we have:

{
var note = this.makeNote(...);
var someID = note.id;
this.notes[someID] = note;
console.log(this.notes[someID] === note);
}

I've omitted all other log calls for simplicity, but I've verified that the note is created with the given data, and that (this instanceof myClass) is true.

However, the last line prints out false. Turns out, this.notes[someID] is undefined, as is this.notes[note.id]. Printing this.notes gives me a long chain of commas, followed by an Object (which would be my note) at the very end.

I'm running out of ideas as to why this isn't working. What can cause an associative array to either place or retrieve incorrectly?

Thank you for your time.