combine two arrays javascript
let arr1 = [0, 1, 2];
let arr2 = [3, 5, 7];
let primes = arr1.concat(arr2);
// > [0, 1, 2, 3, 5, 7]
combine two arrays javascript
let arr1 = [0, 1, 2];
let arr2 = [3, 5, 7];
let primes = arr1.concat(arr2);
// > [0, 1, 2, 3, 5, 7]
concat
const array1 = [
{
"id": 2,
"name": "Ijtimoiy hayot",
"user_id": null,
"color": "#230A75"
},
{
"id": 3,
"name": "O'z-o'zini rivojlantirish",
"user_id": null,
"color": "#64E9D8"
}
];
const array2 = [
{
"id": 0,
"name": "Boshqalar",
"user_id": null,
"color": "#95289A"
},
{
"id": 1,
"name": "Oziq - Ovqat",
"user_id": null,
"color": "#26a0fc"
}
];
const array3 = array1.concat(array2);
console.log(array3);
// expected output: Array ["a", "b", "c", "d", "e", "f"]
concat
const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = array1.concat(array2);
console.log(array3);
// expected output: Array ["a", "b", "c", "d", "e", "f"]
string concatenation in js
var str1 = "Hello ";
var str2 = "world!";
var res = str1.concat(str2);
console.log(res);
javascript string concat vs +
It is strongly recommended to use the string
concatenationoperators (+, +=) instead of String.concat
method for perfomance reasons
concat js mdn
const array1 = ['a', 'b', 'c'];
const array2 = ['d', 'e', 'f'];
const array3 = array1.concat(array2);
console.log(array3);
// expected output: Array ["a", "b", "c", "d", "e", "f"]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us