Just started learning JS, so there's still a lot to discover
While browsing, I stumbled upon this interesting information (See Image) on https://www.w3schools.com/js/js_array_methods.asp
According to them, "JavaScript automatically converts an array to a comma separated string when a primitive value is expected."
They claim that on their website, it should return the same result (String)
However, when I tested it on Chrome Console, I got different results:
const fruits = ["Banana", "Orange", "Apple", "Mango"];
console.log(fruits);
Result: (4) ['Banana', 'Orange', 'Apple', 'Mango']
0: "Banana"
1: "Orange"
2: "Apple"
3: "Mango"
length: 4
It's important to note that this returns an Array
const fruits = ["Banana", "Orange", "Apple", "Mango"];
console.log(fruits.toString());
Result: Banana,Orange,Apple,Mango
This, on the other hand, returns a string
If anyone could clarify which method is correct, I would greatly appreciate it
Thank you