+ 2

How do you use the push() method to add an entire array to another array?

Array methods

12th Jan 2020, 1:45 PM
Fakile Razaq
Fakile Razaq - avatar
3 Antworten
+ 3
Javascript? Create the array separately, then push it into the other array like any other item.
12th Jan 2020, 1:48 PM
HonFu
HonFu - avatar
+ 2
Like this ? var c1 = [56, 20, "Loren"]; var c2 = [63, 94, "khalid"]; c1.push(c2); console.log(c1); Tried this several time, it outputs undefined ...
12th Jan 2020, 1:53 PM
Fakile Razaq
Fakile Razaq - avatar
+ 2
I just copypasted your code snippet and ran it - it worked!
12th Jan 2020, 2:11 PM
HonFu
HonFu - avatar