Copy link to clipboard
Copied
Why do these two methods of presenting the contents of an array, where one or more elements is set to 'null', give a different display?
var x
x = [ 1, null, null ];
$.writeln( x );
$.writeln( x[0] + "," + x[1] + "," + x[2] );
The results displayed are:
1,,
and:
1,null,null
respectively.
It's consistent regardless of whether x is declared as above, or as: 'new Array', or as: 'new Array( 3 )'.
Just wondering. It had me chasing my tail for a while during debugging.
Copy link to clipboard
Copied
Not an answer, but when in the additional line you type: x[1], so directly cell of an array, you'll have null displayed. Probably the same happens when you put specified cell to writeln. For a reason in array they still exist as they are, so as true values in the contrary to calling a single input. Then they are shown as result so in the understable converted form. You do not need that but you can try to make string from array by x.toSource()
Copy link to clipboard
Copied
Indeed, as you say and as I showed, x[1] an be shown to contain 'null'.
My issue in debugging was that the array could contain blank - i.e., "" - elements, so a display of ',,' wasn't helping me.
I'll mark this as 'Assumed Closed', as I guess its a 'feature'.
Copy link to clipboard
Copied
Good point about problem with distingishing null from '' in this case. The only what can be done is: $.writeln(x.toSource())
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more