Subj : Re: TypeError: redeclaration of const
To   : echicken
From : Mortifis
Date : Mon Aug 19 2019 12:34 pm


> The Synchronet webserver reuses the same JS context across multiple requests
> from the same client.  It can take a few minutes for the client's session to
> expire and a new context to be created.  So basically you may end up reusing
> the same global scope across multiple executions of a script.

> So using 'const' at the *top level* of an XJS/SSJS script is inadvisable.
> Use 'var' instead.

> It's okay to use 'const' inside of functions.

> It's probably also okay to wrap your entire script in an IIFE so that you
> get a fresh scope for each request.  However, this context reuse was done
> for performance reasons, so you'd be sacrificing any performance gain by
> doing that.

> (function () {
>   // This is an IIFE
>   // It's an Immediately Invoked Function Expression
> })();


Excellent, thank you!


My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

---
� Synchronet � AlleyCat! BBS - http://alleycat.synchro.net:81