I'm wondering what is better to Imagine in a library I have an object that stores some variables. Some of them do not fit semantically or contextually in that variable but they are used for some functions in that object. Would be better to store them inside that object as private variables if I want them not to be used except by those functions, or to declare them externally inside the IIFE that prepares the library and use those variables as closures?
Imagine:
let func = (function(){
let func = function(){
let a = "hello";
this.sayHello = function(){
alert(a);
};
}
//Extend object etc and do some other things.
return func;
})();
OR
let func = (function(){
let a = "hello";
let func = function(){
this.sayHello = function(){
alert(a);
};
}
//Extend object and do some other things.
return func;
})();