This is not a problem, just personal curiosity.
I've found a weird edge-case and I don't know if my brain is messing up or if JavaScript simply lacks this. From an SQL-Query that returns columns of Strings that can also be null, I want to put them into an array. However, I want those arrays to be empty when the strings are null.
If I do the following, the arrays will contain null as entry instead of staying empty:
// Column A and B can be either a String or null
var sqlColumnA = sqlResults[i][1];
var sqlColumnB = sqlResults[i][2];
// Store them within arrays of an objects ONLY IF they are a String
var obj = {
a : [sqLColumnA],
b : [sqlColumnB]
};
To bypass this, I'd have to use a ternary operator like this:
sqlColumnA === null ? [sqlColumnA] : []
Obviously it works, but it got me thinking. Is there something like Nothing in JavaScript? Where a variable isn't just null, but literally empty? Or will I not be able to bypass the ternary operator solution?