i have multi-dimensional array different types of variables, this:
array = [ [[file, name, visible], [arraypoint, arrayother], ...], [[file2,...], ..] ]
now in code multiple times have call (for example) array() of points located in myarray [x] [1] [0].
i wanted know if there possibility of creating definitions or pointers array position shorten code, because not remember variable positions.
// access value @ address available in pointer var *pointarray = &myarray[x][1][0]; // code *pointarray.push(pint_x, point_y); ============== vs ============== myarray[x][1][0].push(pint_x, point_y);
thank much!! , evening.
by marco.
if do
var pointarray = myarray[x][1][0];
it make copy of reference array @ myarray[x][1][0]
. therefore, subsequent mutations elements of pointarray
change elements of myarray[x][1][0]
.
note reassigning new value pointarray
whole not effect myarray[x][1][0]
, since make pointarray
store else.
assignments not copy/clone objects in javascript, make variable on left-hand side reference same object what's on right-hand side.
var outer = [[0,1,2],[3,4,5]]; var inner = outer[1]; inner.push(6); console.log(json.stringify(outer)); inner = []; console.log(json.stringify(outer));
Comments
Post a Comment