Can't Any Variable Be Made Global by Returning It's Value Within a Function?


Just as the title asks… Can’t any (local) variable be made global by simply returning it’s value within a function? Isn’t return solely for the purpose of using a variable outside of the code block it was originally defined in?

Thank you!


that doesn’t make it a global variable. If we do:

var example = function(){
    var x = "hello world"
    return x


we don’t have any global variable



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.