Digression: To determine whether an object is a problem that is not an array. For a Web page, or a global scope, the instanceof operator can be used to achieve satisfactory results:
if (value instanceof Array) {
}
The problem, however, is that the instanceof operator assumes that there is only one global execution environment. If a Web page contains more than one frame, there is actually more than two different global execution environments, so there are more than two different versions of the array constructor. If you pass an array to another frame from one frame, the passed-in array has its own different constructors than the array created in the second frame. To solve this problem, you can use the Array.isarray () method. The purpose of this method is to determine in the end whether a value is an array.
Conversion method:
As previously sued, all objects have the tolocalestring () ToString () valueof () method, where the call to the ToString () method of the array returns a comma-delimited string of strings of each value in the array. And the call to ValueOf () returns an array. In fact, in order to create this string, the ToString () method for each item of the array is invoked.
var colors=["Red", "Blue", "green"];
Alert (colors.tostring ()); Red,blue,green
Alert (colors.valueof ()); Red,blue,green
alert (colors); Red,blue,green
Because alert () receives a string parameter, he calls the ToString () method in the background, resulting in the same result as a direct call to the ToString () method. In addition, the tolocalestring () method often returns the same value as the valueof () and ToString () methods, but not always, when the toLocaleString () method of an array is invoked, it also creates a comma-delimited string of array values