In a return of a method I have a resulting dictionary, sometimes it may come empty, hence I have trouble identifying when it is empty or not.
for(var i = 1; i <= this.last; i++)
{
this.select(i, (item) =>
{
console.debug(JSON.stringify(item));
if(item != null)
all.push(item);
});
}
The output of the debug is as follows:
database.ts:104 {"id":"1","descricao":"Alimentação"}
database.ts:104 {"id":"2","descricao":"Transporte"}
database.ts:104 {"id":"3","descricao":"Saúde"}
database.ts:104 {"id":"4","descricao":"Educação"}
database.ts:104 {}
database.ts:104 {}
database.ts:104 {"id":"7","descricao":"Mais uma conta"}
I want to execute all.push(item)
only when item is not vazio
, I tried to use .length
but it does not work, I put console.log(item.length)
and in all cases it returns undefined
. How can I check if it is empty?