Defining Multiple Variables With One `var` Keyword In Javascript
I have a line in my source code written by someone else: var campaignLimits = 10, campaignsArray = new Array(); I just wanted to know, whether campaignsArray here becomes global v
Solution 1:
Assuming you have not used any programming pattern, If its written inside a function then its not global.
(function() { var campaignLimits = 10, campaignsArray = newArray(); })();
as @phoa commented it is same as
(function() { var campaignLimits = 10; var campaignsArray = newArray(); })();
Try it in your console and see whether you will be able to access campaignsArray.
Post a Comment for "Defining Multiple Variables With One `var` Keyword In Javascript"