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 variable, or the var
applies to campaignsArray
as well?
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 variable, or the var
applies to campaignsArray
as well?
Assuming you have not used any programming pattern, If its written inside a function then its not global.
(function() { var campaignLimits = 10, campaignsArray = new Array(); })();
as @phoa commented it is same as
(function() { var campaignLimits = 10; var campaignsArray = new Array(); })();
Try it in your console and see whether you will be able to access campaignsArray.