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?
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]: () => {...} }