Property 'length' does not exist on type '{}'


#1

I have an variable define as array, but how can I verify if the array size is not empty? I tried the code below, but the code has error and the error message is Property 'length' does not exist on type '{}'

public dailyUseItems:{};

this.hasDailyUseItems = this.dailyUseItems.length > 0;

#2

Are you absolutely sure it’s really an array?


#3

The value as below
{‘Name’:‘abc’,
‘Age’:12},
{‘Name’:‘cde’,
‘Age’:14}


#4

Sorry, my mistake there. I didn’t see enclosing brackets, so I assumed you had an object.


#5

But how can I verify if this array/object is empty?


#6

To declare an array variable, declare it this way

or

To check the length of array


#7

Sir i use this but i got error ‘any’ only refers to a type, but is being used as a value here.


#8

Would you be so kind to put your code here? Thanks.