I was looking at the first table on http://zero.milosz.ca/, and wanted to understand why, for example, 0 == [] and 0 != {}. I’m assuming it’s because Number([]) == 0 and Number({}) == NaN. However, that part seems arbitrary. Why is an empty list 0 and empty object a NaN?
I was looking at the first table on http://zero.milosz.ca/ , and wanted to understand
Share
Using
Number(some_object)will use the string representation of the given object. For your examples the string representations are:The string
'[object Object]'cannot be converted to a number but the empty string''can.