i am trying to combine two arrays, i tried this:
const admin_navigation = [...AdminNav, ...initialNav] - not working right its over writing one array
i also tried,
const admin_navigation = AdminNav.concat(initialNav); - give me an error (TypeError: AdminNav.concat is not a function)
what i am trying to create is one array that combine both arrays into one like the bottom example.
=== Array 1 ===
const initialNav = {
items: [
{
name: "Test Page",
url: "/test/testpage",
icon: "icon-drop",
},
{
name: "Test Page2",
url: "/test/testpage2",
icon: "icon-drop",
},
],
};
=== Array 2 === (comes from my reducer)
const AdminNav = {
items: [
{
title: true,
name: "ADMINISTRATOR22",
wrapper: {
// optional wrapper object
element: "", // required valid HTML5 element tag
attributes: {}, // optional valid JS object with JS API naming ex: { className: "my-class", style: { fontFamily: "Verdana" }, id: "my-id"}
},
class: "", // optional class names space delimited list for title item ex: "text-center"
},
{
name: "Forms",
url: "/base/forms",
icon: "icon-puzzle",
},
],
//loading: false,
};
i need the results to be like this:
const NewNav = {
items: [
{
title: true,
name: "ADMINISTRATOR22",
wrapper: {
// optional wrapper object
element: "", // required valid HTML5 element tag
attributes: {}, // optional valid JS object with JS API naming ex: { className: "my-class", style: { fontFamily: "Verdana" }, id: "my-id"}
},
class: "", // optional class names space delimited list for title item ex: "text-center"
},
{
name: "Forms",
url: "/base/forms",
icon: "icon-puzzle",
},
{
name: "Test Page",
url: "/test/testpage",
icon: "icon-drop",
},
{
name: "Test Page2",
url: "/test/testpage2",
icon: "icon-drop",
},
],
};
concat[...arr1, ...arr2]