Comment

Comment by Alifatisk

Interesting, what exactly is it I am looking at?

const resource = { [Symbol.dispose]: () => { console.log("Hooray!"); }, };

An object called resource, consisting on a anonymous function that logs Horray to the console. This is all fine and I am used to that.

The interesting part that stuck with me is "[Symbol.dispose]:". Why is it in a Array? What does this exactly do? It marks the anonymous function as disposable at the end of the code block? Correct?

{ [Symbol.dispose]: () => {...} }

parent Alifatisk 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton