Easy6E
Deno14mo ago
Easy6

Content of UInt8Array changed by returning it from function

Completely, utterly baffled by this.

async function a(): {Promise<{
b: Uint8Array;
mediaType: string;
} {

// ....
const result = { b: resizedImage, mediaType: image.mediaType };
return result;

// Putting a breakpoint at the result, the content of Uint8Array b starts with [82, 73, 70, ..]

async function b() {
// ....
const result = await a();
console.log(result);

// Now, after the return, the content of "result.b" starts with [16, 227, 103, ..]

The only code that has been executed was the "return" line, yet the array changed. How is this possible? The array does stay the same size.
image.png
image.png
Was this page helpful?