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.

do need worry rewriting thing? (or browsers maintain track if ever modified, , if wasn't won't rewrite it)

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

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -