How to reset JS state?

Hi again,
I have some state in JS for a particular page. That state changes whilst the user is using the page so if the user navigates away from the page I want to reset the JS state. Something like this (in pseudo code):

<Deactivated ExecuteSomeJs="{resetJsState}"/>

What’s the best way to do this?
Thanks!

Handling the JS state manually is the right way to go, since you should always have full control over it. If you’re up to resetting the “state” from a JS function, then your pseudo code is pretty close. Here’s actual Fuse code for the same thing:

<JavaScript>
function resetJsState() {
    // ...
}
module.exports = {
    resetJsState: resetJsState
};
</JavaScript>
<Deactivated>
    <Callback Handler="{resetJsState}" />
</Deactivated>

An alternative for lazy prototyping that comes at a significant processing power cost is described in this forum thread.

Great - thank you