-
I restructured my data in "days" a few times and lost understanding of what I was dealing with. I thought that it was an object as I couldn't reference its contents with an index e.g
console.log(days[2].hour);
Firefox console says:
TypeError: days[2] is undefined
If it's an array after all, then I'll do some more reading about arrays. Thanks
-
Tue 2020.02.04
'I'm trying to access a propety of an object which changes depending on the output of a function'
I get that some identifier will be returned from the results of a completed task within a function. And, . . . that value will somehow reference items in a list perhaps?
@user101594 are we attempting to work with an array, or Json Object Notation?L1 in code block found in post #1 is creating a Javascript variable whose content is a JSON object.
Is the attempt to reference that JSON object 'key' by 'name' and extract it's corresponding 'value'?
. . . or, . . .
Is the thinking to access an array by it's indexer? Or an array of a two dim array elements by an indexer?
ref: snippets in post #5
I'm not at a development station with an active Espruino device connected, doing the following from memory. . . .
Debug tip should this not yet be understood
Typing
dump()
in Left-Hand console should reveal if declared variables are initialized.http://www.espruino.com/Reference#l__global_dump
ref: second snipper in post #1
'Uncaught Error: Cannot read property 'hour' of undefined'Entering the variable by name
days
should do the same. This might also provide a clue as to how the Espruino WebIDE sees what is declared and how it is initialized, and might clear up some mental insight.
Mon 2020.02.03
@user101594
to learn
Asking here was a good choice to start the learning process
Asking there will be the choice to resolve
W3Schools has always been a good place to start:
Array String Indexers