javascript - Should heavy variables go outside functions? -
javascript - Should heavy variables go outside functions? -
i have function runs around 200 times.
the function this:
function getb(av,bol){ var bxes=[ ["11","12","13","21","22","23","31","32","33"], ["14","15","16","24","25","26","34","35","36"], ["17","18","19","27","28","29","37","38","39"], ["41","42","43","51","52","53","61","62","63"], ["44","45","46","54","55","56","64","65","66"], ["47","48","49","57","58","59","67","68","69"], ["71","72","73","81","82","83","91","92","93"], ["74","75","76","84","85","86","94","95","96"], ["77","78","79","87","88","89","97","98","99"] ]; //code }
my first concern array slowing downwards because think rewriting each time array bxes
(or that)
this bxes
array never modified , wouldn't mind create global.
why wouldn't move outside function? (why risk causing performance issue?)
it wouldn't have "global" - in parent scope of function - both function , bxes
, other code exist in parent function or closure...
(function(){ var bxes = [...]; window.getb = function(av,bol){...}; })();
javascript performance
Comments
Post a Comment