Hi, I noticed that you can make local functions and “global” functions, however I had a few questions that weren’t answered by other posts I read.
-
When people say a global function, it means it can be accessed everywhere in the script regardless of scope, and its’ not being added into _G right?
-
Creating a global function inside another function would essentially just create a function, however I’m going to assume when you declare that nested function it’ll be saved in memory and won’t be recreated each time you call the function?
-
What is the “performance” difference if there is one between local functions and global functions, and should I always declare a function as local, unless I need it to be access able regardless of scope?
-
How do global variables work compared to local variables? Do they doing called “hoisting”, and put the declaration of the variable at the top of the script during runtime or something?
-
Why is returning local functions through a modulescript or generally returning it not valid?