34 lines
697 B
JavaScript
34 lines
697 B
JavaScript
/**
|
|
* Private `concat` function to merge two array-like objects.
|
|
*
|
|
* @private
|
|
* @param {Array|Arguments} [set1=[]] An array-like object.
|
|
* @param {Array|Arguments} [set2=[]] An array-like object.
|
|
* @return {Array} A new, merged array.
|
|
* @example
|
|
*
|
|
* _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
|
|
*/
|
|
export default function _concat(set1, set2) {
|
|
set1 = set1 || [];
|
|
set2 = set2 || [];
|
|
var idx;
|
|
var len1 = set1.length;
|
|
var len2 = set2.length;
|
|
var result = [];
|
|
idx = 0;
|
|
|
|
while (idx < len1) {
|
|
result[result.length] = set1[idx];
|
|
idx += 1;
|
|
}
|
|
|
|
idx = 0;
|
|
|
|
while (idx < len2) {
|
|
result[result.length] = set2[idx];
|
|
idx += 1;
|
|
}
|
|
|
|
return result;
|
|
} |