typescript: Encapsulate In reality Non-public Variables in a Closure

Closures are an alternative choice to really non-public magnificence fields. If you want to encapsulate a personal variable in order that it will probably best be accessed in a managed means, you’ll use a closure. This method is especially helpful when your code has to run in older JavaScript environments that do not but toughen really non-public magnificence fields or the ES2015 WeakMap information construction.