What’s the sum of an empty object and an empty array in JS? Is there any length
to be found?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Once again, we’re dealing with type conversion in JavaScript.
Both an empty array and an empty object will be converted to strings.
In the case of an empty array, it will be an empty string.
But for the empty object, we get the string [object Object]
!
The length of this string is greater than 10, so we’ll see the first message logged to the console.
More examples of JavaScript typecast are covered here.
ANSWER: the string wow, this is quite long
will appear on the screen.
Top comments (0)