Hi people! 
Well, it's me again with another doubt...
In my plugin I have a lot of this:
So, to keep the lines short, I have assigned these codes to variables, inside the scope of the function:
But the case is, that I have a lot of functions.
My lines get short. But in return, I add many lines to the code.
With that, I came to thinking...
Question 1 - Declaring those variables inside of the scope of the functions, many times like in the example above, can cause me a performance issue?
What is best to do:
Option A - Declare those variables one time, outside the function. And then, only change its value inside the function.
Option B - Don't use the variables. Instead, use the code itself inside the function:
Option C - Do the plugin like in the firsts example, declaring variables inside each function.
Or I'm worrying too much about all of this. And the way that I do that doesn't matter to javascript, in terms of performance?
Question 2 - Declaring variables with LET keyword outside of functions will allow other plugins to modify or have access to those variables (if they use variables with the same name)?
Well, it's me again with another doubt...
In my plugin I have a lot of this:
Code:
SceneManager._scene._helpWindow;
SceneManager._scene._categoryWindow.currentSymbol();
Eli.Param.HelpWindows.menuText;
Eli.Param.HelpWindows.etc;
Code:
function myFunction() {
const thisHelp = SceneManager._scene._helpWindow;
const thisSymbol = SceneManager._scene._categoryWindow.currentSymbol();
const thisText = Eli.Param.HelpWindows.menuText
thisHelp.x = 100;
};
function myFuntion2() {
const thisHelp = SceneManager._scene._helpWindow;
const thisSymbol = SceneManager._scene._categoryWindow.currentSymbol();
const thisText = Eli.Param.HelpWindows.etc;
thisHelp.x = 100;
}
My lines get short. But in return, I add many lines to the code.
With that, I came to thinking...
Question 1 - Declaring those variables inside of the scope of the functions, many times like in the example above, can cause me a performance issue?
What is best to do:
Option A - Declare those variables one time, outside the function. And then, only change its value inside the function.
Code:
let thisHelp = null;
let thisSymbol = null;
let thisText = null;
function myFunction() {
thisHelp = SceneManager._scene._helpWindow;
thisSymbol = SceneManager._scene._categoryWindow.currentSymbol();
thisText = Eli.Param.HelpWindows.menuText
thisHelp.x = 100;
};
function myFuntion2() {
thisHelp = SceneManager._scene._helpWindow;
thisSymbol = SceneManager._scene._categoryWindow.currentSymbol();
thisText = Eli.Param.HelpWindows.etc;
thisHelp.x = 100;
};
Option B - Don't use the variables. Instead, use the code itself inside the function:
Code:
function myFunction() {
SceneManager._scene._helpWindow.x
SceneManager._scene._helpWindow.setText(Eli.Param.HelpWindows.etc)
}
function myFunction2() {
SceneManager._scene._helpWindow.x
SceneManager._scene._helpWindow.setText(Eli.Param.HelpWindows.etc)
}
Option C - Do the plugin like in the firsts example, declaring variables inside each function.
Code:
function myFunction() {
const thisHelp = SceneManager._scene._helpWindow;
const thisSymbol = SceneManager._scene._categoryWindow.currentSymbol();
const thisText = Eli.Param.HelpWindows.menuText
thisHelp.x = 100;
};
function myFuntion2() {
const thisHelp = SceneManager._scene._helpWindow;
const thisSymbol = SceneManager._scene._categoryWindow.currentSymbol();
const thisText = Eli.Param.HelpWindows.etc;
thisHelp.x = 100;
}
Or I'm worrying too much about all of this. And the way that I do that doesn't matter to javascript, in terms of performance?
Question 2 - Declaring variables with LET keyword outside of functions will allow other plugins to modify or have access to those variables (if they use variables with the same name)?


