why do we use var , when we can simply write a function with name myConcat
var myConcat = function(arr1, arr2) {
"use strict";
return arr1.concat(arr2);
};
why do we use var , when we can simply write a function with name myConcat
var myConcat = function(arr1, arr2) {
"use strict";
return arr1.concat(arr2);
};
Probably because the lesson or challenge you took that code from is specifically teaching you a specific form of functions called function expression
stored inside variables. There are tons of ways to create and declare functions and this is just one of those.