Record Collection solution vs previous example

Tell us what’s happening:
I can come up with the solution fine, but I like to read the hint section to see how what I wrote compares to the given solution.

After reading the solution, I found a part I don’t understand


I understand this to return the actual data if there is any, and I would assume undefined if not. I can understand how undefined could be a false value, but how could say, an empty array be a true value?

if you used collection[1245]["tracks"] for example.

I used the condition if(collection[id].hasOwnProperty(prop)) Because I understood this to be used when accessing properties and desiring a true/false return as demonstrated in a previous example… When should I choose to instead use the the given solution?

Thank you for your time.

The if statement returns true/false and not the value of the property, all values except false, 0, "", null, undefined, and NaN are true in javascript, an empty array therefore would also be true , the length of the empty array would be however false, since it is 0.

refrence: Truthy - MDN Web Docs Glossary: Definitions of Web-related terms | MDN