I'm mainly interested in the Object.prototype.toString method. Both are operating on arrays but the Object.prototype.toString does something different to the output. Why is this?
Outputs: 1, 2, 3
console.log([1,2,3].toString());
Outputs: blank
console.log([].toString());
Outputs: [object Array]
return Object.prototype.toString.apply([]);
Because Array.prototype.toString is a different function to Object.prototype.toString.
The designers of the function decided to make Array stringification output the data in the array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With