javascript - concatenation of two arrays -


i have array:

$scope.array2 = ["3","4","5"]; $scope.array = [["1"],["2"],["3"]]; $scope.array[0].concat(array2); 

expected output:

$scope.array = [["1","3","4","5"],["2"],["3"]]; 

but array unchanged after concat. how can solve problem?

to desired result, you'd have this:

$scope.array2 = ["3","4","5"]; $scope.array = [["1"],["2"],["3"]]; $scope.array[0] = $scope.array[0].concat($scope.array2); 

array.prototype.concat returns result, instead of modifying it's subject.
you'll have save result of contact $scope.array[0].


also, have @ @phil's answer, using push, returns desired result, without having assign result separately.


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -