I am trying to figure out the best practices for scoping "constants" in JavaScript. To be clear, the reference to "constant" may be misleading. The question is aimed at how to properly scope such variables. How to declare and use them.
For example, I can write some code like:
var StormData = (function () {
/**
* @constructor
*/
StormData = function () {
this.atcID = undefined;
this.name = undefined;
this.entries = [];
};
StormData.prototype = {
// Constants
REVISION: "1.1"
];
return StormData;
})();
Unfortunately, since the code is an IIFE, JS says it can't find the variable "REVISION". I don't want to use ES2016 or more modern versions of JS with "const" since the support across browser/tools is uneven. I just want to use "plain" JavaScript - no ES6, no TS, etc. There are various convoluted ways to do this (just look around in SO). I could skip the IIFE, but that seems a poor solution. Short of a more modern version of JavaScript, is there a "best" way to do this?