I have seen dozens of questions asked for checking if an array is empty. But I can't find the question on how to check if the first item in an array is empty.
Currently, I am doing this check on this way, but I highly doubt that it is the correct way to do this.
var specialtiesListArray = ['', 'not', 'empty', 'value'];
if (specialtiesListArray[0] == '') {
specialtiesListArray.shift(); // <== Removing the first item when empty.
}
console.info({ specialtiesListArray });
The above works fine, but I am wondering is this ok? Are there better ways. And if someone knows a duplicate, then please let me know. I gladly delete the question if it has already been answered.
pd.isnull(x) or not bool(x)would be pretty good at finding empty values.===in place of==, in this way if you have empty arrays or zeros it won't delete the element. Remember that in JS[] == ''or0 == ''are true