I'm getting a output data from a device as series of array. This array comes 5 times each time carrying a 64 item in it while swiping a card into the device. I want to concat these array. Below is the final array I got. I know array.concat(array2)
should work but due to some reason it is not. Can anybody tell me what am I doing wrong here or any suggestion
(5) [Uint8Array(64), Uint8Array(64), Uint8Array(64), Uint8Array(64), Uint8Array(64)] 0 :
Uint8Array(64) [2, 86, 105, 86, 79, 116, 101, 99, 104, 50, 0, 2, 0, 0, 238, 200, 223, 238, 35, 130, 0, 213, 2, 207, 0, 128, 91, 55, 37, 0, 3, 131, 1, 9, 37, 42, 53, 49, 57, 54, 42, 42, 42, 42, 42, 42, 42, 42, 48, 53, 50, 50, 94, 75, 65, 78, 73, 77, 79, 90, 72, 73, 32, 32] 1 :
Uint8Array(64) [3, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 47, 94, 51, 53, 48, 53, 42, 42, 42, 63, 42, 59, 53, 49, 57, 54, 42, 42, 42, 42, 42, 42, 42, 42, 48, 53, 50, 50, 61, 51, 53, 48, 53, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 63, 42, 214] 2 :
Uint8Array(64) [3, 110, 241, 211, 17, 223, 130, 10, 242, 35, 65, 176, 170, 72, 224, 121, 99, 248, 102, 252, 131, 180, 174, 84, 98, 54, 209, 168, 39, 193, 225, 129, 138, 114, 155, 135, 73, 118, 101, 68, 229, 32, 42, 91, 254, 210, 26, 189, 197, 26, 64, 21, 112, 196, 228, 181, 216, 218, 56, 94, 46, 77, 43, 130] 3 :
Uint8Array(64) [3, 72, 80, 22, 34, 37, 108, 147, 123, 170, 72, 79, 190, 73, 86, 3, 108, 152, 228, 68, 253, 69, 18, 101, 201, 56, 114, 142, 156, 174, 55, 197, 194, 98, 153, 73, 2, 0, 0, 1, 64, 2, 136, 186, 104, 3, 159, 57, 1, 144, 255, 238, 1, 5, 223, 238, 48, 1, 12, 223, 238, 38, 1, 200] 4 :
Uint8Array(64) [4, 120, 136, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] length : 5
proto : Array(0)
Merge Array with Push:
const array1 = [2, 7, 4];
const array2 = [3, 5,9];
array1.push(...array2);
console.log(array1)
Using Concat and Spread operator:
const array1 = [1,2];
const array2 = [3,4];
// Method 1: Concat
const combined1 = [].concat(array1, array2);
// Method 2: Spread
const combined2 = [...array1, ...array2];
console.log(combined1);
console.log(combined2);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加