Is the .data from JS Query undefined or null?

  • The Problem
    I was trying to disable a query based on if it's been ran and it's results. in one window it says .data is undefined and in the other it says null.

  • How it Happened
    I added an input query to a Module and set the test value for it as a query that returns the same type of data. if you try and Run the proxy query for the input it shows an error saying "No query provided for .company_icon_query". This is what sets .data to undefined in the proxy query (company_icon_query).
    As to how the inspection window says null and not undefined happened, I have no idea.

  • Findings
    made a truth table of sorts to show it's null not undefined: === undefined : false (undefined was added in Ecmascript 5)
    typeof === "undefined" : false
    typeof === typeof undefined : false
    typeof === void(0) : false
    typeof === "object" : true
    null is of type object, so there wasn't much use in continuing.

  • Screenshots:

  • How I Fixed It
    I reset the values of everything and it fixed itself and i haven't been able to duplicate what happened

  • What Happened? (my best guess)
    the inspection and debug windows are capable of displaying undefined so there isn't a problem there and since null is the actual value, it would point towards the debug window having a bug in the evaluation between undefined and null.

  • Future Proofing a Solution (maybe)
    interestingly, in JS, when using abstract equality both null and undefined end up being checked:
    {{ == null }}
    {{ == undefined }}
    if .data is null or undefined, both of the above will return true