Tag: The result is the operation part of the cat start element specifying the description
1.var arr = ["One", "one", "three"];
var arrto = arr;
ARRTO[1] = "Test";
Document.writeln ("Original value of the array:" + arr + "<br/>");//export: Original value of the array: One,test,three
Document.writeln ("New value of the array:" + Arrto + "<br/>");//export: The new value of the array: One,test,three
Like the direct assignment above is a shallow copy, many times, this is not the result we want to get, in fact, we want the value of arr is not changed, right?
2.
For the slice function of the array object,
Returns a segment of an array. (still an array)
Arrayobj.slice (start, [end])
Parameters
Arrayobj
Required option. An Array object.
Start
Required option. The start element of the section specified in Arrayobj is the zero-based subscript.
End
Options are available. The end element of the part specified in the arrayobj is the zero-based subscript.
Description
The slice method returns an Array object that contains the specified portion of the arrayobj.
The slice method has been copied to the element specified by end, but does not include the element. If start is negative, it is processed as length + start, where length is the number of the array. If end is negative, it is treated as a length + end, where long is the number of the array. If End is omitted, then the slice method is copied to the end of arrayobj. If End appears before start, no elements are copied into the new array.
var arr = ["One", "one", "three"];
var Arrtoo = arr.slice (0);
ARRTOO[1] = "Set Map";
Document.writeln ("Original value of the array:" + arr + "<br/>");//export: Original value of the array: One,two,three
Document.writeln ("New value of the array:" + Arrtoo + "<br/>");//export: The new value of the array: One,set Map,three
The Concat () method is used to concatenate two or more arrays.
The method does not alter the existing array, but only returns a copy of the concatenated array.
Grammar
Arrayobject.concat (Arrayx,arrayx,......, Arrayx)
Description
Returns a new array. The array is generated by adding all the Arrayx parameters to the Arrayobject. If the argument for the concat () operation is an array, then the element in the array is added, not the array.
var arr = ["One", "one", "three"];
var arrtooo = Arr.concat ();
ARRTOOO[1] = "Set Map to";
Document.writeln ("Original value of the array:" + arr + "<br/>");//export: Original value of the array: One,two,three
Document.writeln ("New value of the array:" + arrtooo + "<br/>");//export: The new value of the array: One,set Map to,three
Array Assignment changes