What is the point/result of calling concat with no parameters? E.g.
Code:
var board = [
false, false, false, false,
false, false, false, false
];
board = board.concat();
Concat function is used for concatenation of two Arrays in javascript.
For Example:
a = [1,2,3]
b = [4,5]
a = a.concat(b); // a becomes [1,2,3,4,5]
Using concat with no arguments can be used to copy an array. For example:
var a = [1,2,3];
var b = a.concat();
b.push(4);
// a is [1,2,3] and b is [1,2,3,4]
Read this from MDN concat source
concat does not alter this or any of the arrays provided as arguments but instead returns a shallow copy that contains copies of the same elements combined from the original arrays. Elements of the original arrays are copied into the new array
Note: concat() is a function not a parameter.
If you call concat() without a parameter, you will get a new array as a result. See the summary below.
var board = [ false, false, false, false, false, false, false, false ];
board = board.concat(); // Will return a new copy of your board array.
You may provide an argument to the concat(value1, value2, ..., valueN) function:
N Arrays and/or values to concatenate to the resulting array.
You can read up on the documentation here: Array.prototype.concat() @ MDN
Summary
The concat() method returns a new array comprised of this array joined with other array(s) and/or value(s).
Example
var alpha = ["a", "b", "c"];
var numeric = [1, 2, 3];
// creates array ["a", "b", "c", 1, 2, 3]; alpha and numeric are unchanged
var alphaNumeric = alpha.concat(numeric);
String board[]isn't JavaScript.concat()is a function not a parameter.