I have js object that has data which contains numbers. Some of them can be 0
. In that case if statement will evaluate those values as an empty strings. Here is example:
var dataObj = {
"one": 13,
"two": 0,
"three": 3
}
$.each(dataObj, function (j, k) {
if(k){
console.log('Column: '+k);
}else{
console.log('Empty');
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
I'm wondering how this can be prevented? Is there a way to check if value is empty but at the same time not consider 0
as an empty value?