Given I'm operating on some sort of sensitive data, e.g. decrypted secret, and I wanna dispose it as soon as I don't need it anymore, is there an effective way of doing that in JS?
For example, would something like this
let secret = null;
secret = getSecretSomehow();
useSecretSomehow(secret);
secret = null; // clear secret
do the trick, i.e. would secret
stop existing in memory at that moment, and it wouldn't be possible to get it if one dumps the device memory after that line was executed, or are there any JS runtime caveats which would render it ineffective?
To clarify and make the question more precise - assume we don't put that data to DOM or whatever, it only exists as a variable.