Returns the environment for a function (or the global environment). If the environment has a __environment metatable, that value is returned instead.
See also Lua library functions.
Signature:
env = getfenv([f]) or getfenv([stackLevel])
Arguments:
f- A function (function)stackLevel- Level of a function in the calling stack (number)
Returns:
env- Table containing all variables in the function's environment, or the global environment ifforstackLevelis omitted (table)
This function is defined in the Lua standard libraries