Remix.run Logo
sheept 4 hours ago

You probably meant [object Object] :) Since arrays have their own default toString implementation (its own can of worms that is the basis for JSFuck[0]), you'd have to go out of your way with Object.prototype.toString.call to get [object Array]

[0]: https://jsfuck.com/ relies on Array#toString for casting values to strings

moritzwarhier 3 hours ago | parent [-]

I intentionally corrected it, because vanilla JS arrays used to behave like this in some contexts, but I'm not even sure about which ones still.

Since the "Array" is a reference to the prototype, I think it might be outdated due to changes in undefined behavior of runtimes when serializing array objects, or logging them.

I'm pretty sure that [object Array] used to be the result of logging an array at some point.

  Object.prototype.toString
always returns the result of

  Array.prototype.join

per spec, afaik, so for an empty array it's the empty string.