• 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?

    https://www.w3schools.com/js/js_json_syn­tax.asp

    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__glo­bal_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.

  • Wed 2020.02.05

    TypeError: days[2] is undefined
    

    re: post #5

    OPTION BASE ZERO   vs   OPTION BASE ONE

    Referencing the element using indexer 2 when there are only two elements using Option Base Zero, will yield undefined as a result, since there is only element zero and element one.

About

Avatar for user101594 @user101594 started