Array concat()
The concat() method appends one array to another.
When no arguments are passed in, concat() clones the array and returns it. If one or more arrays are passed in, concat() concatenate the those arrays. If the values passed in are not arrays, they are simply appended to the end of the resulting array.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var colors = ["A", "B", "C"];
var colors2 = colors.concat("D", ["E", "F"]);
document.writeln(colors); //A,B,C
document.writeln(colors2); //A,B,C,D,E,F
</script>
</head>
<body>
</body>
</html>
Home
JavaScript Book
Essential Types
JavaScript Book
Essential Types
Array:
- The Array Type
- Array Built-in Methods
- Detecting Arrays
- Get and set array values
- Enumerating the Contents of an Array
- Array Length
- Array join() method
- Array concat()
- Array indexOf()
- Array lastIndexOf()
- Array every()
- Array filter() filters array with the given function.
- Array map()
- Array forEach()
- push() and pop():Array Stack Methods
- push(), shift():Array Queue Methods
- Array reduce()
- Array reduceRight()
- reverse():Reordering array
- Array slice()
- Array some()
- Array splice()
- Array sort()
- toString(), toLocaleString() and valueOf Array
- Array unshift()