What is the best way to return only selected elements from an array (not the entire array)? (When returning only selected individual elements, the correct color, line-type, etc. characteristics (0, 1, 2, indexing) in preMain must remain associated with each element returned from the array.) For example, for the array:
var vArray = new Array(v0, v1, v2, v3, v4, v5, v6, v7);
1) To display only certain array elements on a chart, for example only v0, v1, v4 and v6, what is the best way to express that in code? ( return <what?>)
2) If for each variable, an "if (vX == null) return;" statement exists;
var v0 = <something>
if (v0 == null)
return;
Then is the following an acceptable way to return only certain elements in an array?
return new Array(v0, v1, null, null, v4, null, v6, null);
("null" is used to return nothing for v2, v3, v5, and v7 while acting as place-holder in the array to keep correct line color, etc. characteristics associated with v0, v1, v4 and v6 which are displayed on the chart)
Thanks.
var vArray = new Array(v0, v1, v2, v3, v4, v5, v6, v7);
1) To display only certain array elements on a chart, for example only v0, v1, v4 and v6, what is the best way to express that in code? ( return <what?>)
2) If for each variable, an "if (vX == null) return;" statement exists;
var v0 = <something>
if (v0 == null)
return;
Then is the following an acceptable way to return only certain elements in an array?
return new Array(v0, v1, null, null, v4, null, v6, null);
("null" is used to return nothing for v2, v3, v5, and v7 while acting as place-holder in the array to keep correct line color, etc. characteristics associated with v0, v1, v4 and v6 which are displayed on the chart)
Thanks.
Comment