Red Treasure Book, 5.2.2 conversion method
toLocaleString ()
methods often return the same values astoString ()
andvalueOf ()
methods, but not always. When thetoLocaleString ()
method of an array is called, it also creates a comma-separated string of array values. The only difference from the first two methods is that this time, in order to get the value of each item, thetoLocaleString ()
method of each item is called instead of thetoString ()
method. Take a look at the following example:
Gods, I"ll just go to the code:
alert(people.toString()); //Nicholas,Greg
alert(people.toLocaleString()); //Nikolaos,Grigorios
3. Is the above result obtained because of the two custom methods of the object, or directly through the call? Can you simply tell me what the process is like?