I have an array called "cart" of objects that is initially empty, but structured like this:
cart:[{name:any, rate:number, qty:number, discount:number, subtotal:number}]
When I attempt to add data to it like so:
cart:[{name:any, rate:number, qty:number, discount:number, subtotal:number}];
and then try to get the length using:
Object.keys(this.cart).length
I encounter an error that says:
`TypeError: Cannot convert undefined or null to object`
Additionally, I am seeking ways to clear all elements in an Array.