DenoDDeno
Powered by
JHJ
Denoβ€’2y agoβ€’
1 reply
JH

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
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Uint8Array or Float32Array
NeTTNNeTT / help
3y ago
Deno KV equivalent of 'returning'
somethingelse~Ssomethingelse~ / help
3y ago