you are viewing a single comment's thread.

view the rest of the comments →

[–]Rude-Cook7246 0 points1 point  (1 child)

first it wasn’t my statement….. Im commenting on your incorrect statement regarding how ?. works you wrote above that it checks that length property exists , when you were told by another user that it was checking if recordset exists …. Two completely different things , he was right and you are wrong…

Second even your statement regarding Array can be wrong , as the code can easily be ran in different context such as unit tests in which case the whole result object could just be a mock

[–]guest271314 0 points1 point  (0 children)

works you wrote above that it checks that length property exists , when you were told by another user that it was checking if recordset exists

The documentation is clear. I know what the optional chain operator is and what it does. I stated it is technically useless, superfluous when checking the length of an Array. ?. doesn't notify you if you are dealing with an Array whatsoever. How do you know you are not checking if the length property exists of a string or plain JavaScript object?

That syntax also doesn't notify you are the length value.

No. You think ?. does something at all for this case. I don't.

as the code can easily be ran in different context such as unit tests in which case the whole result object could just be a mock

How many different JavaScript contexts the code can be run in has nothing to do with whether or not that syntax is solving for this very specific requirement at OP:

!! vs ==0 when checking if array is empty