Would it be possible to automatically identify all variables within a specific scope? For example:
var localScope = function() {
var var1 = "something";
var var2 = "else...";
console.log(LOCAL_SCOPE);
};
and have LOCAL_SCOPE
return an object like this:
{
var1: "something",
var2: "else..."
}
I understand that I can manually create a local object to achieve this, but I am interested in a method that automatically identifies all variables without prior knowledge of their existence.