How to check if an object is empty?
ex:
private brand:Brand = new Brand();
I tried:
if(this.brand) { console.log('is empty'); }
not working.
Use Object.keys(obj).length to check if it is empty.
Object.keys(obj).length
Output : 3
Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
1.4m articles
1.4m replys
5 comments
57.0k users