Skip to content
Advertisement

Concatinate different type arrays

suppose, array1 = ['B', 'G', 'R', 'A'], array2 is Uint8Array, how to concatinate these two arrays ?

I used var array3 = array1.concat(array2), but the result seems wrong , and array3.length is alwalys 5, regardless of content of array2.

Advertisement

Answer

You can do:

var array2 = Array.from(uint8Array);
var array3 = array1.concat(array2);
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement