combinations - How to combine/define two variables in 1? -


i'd "define" 2 variables 1 new variable, contains contents/data of both previous variables. let's first variable called 'var a' , second 'var b', can combine 2 in new variable this?

var = var + var b; 

..or how correct syntax this? hope isn't abstract? ;)

var , b both variables defining external geojson files, , i'd able "combine" these 2 in 1 new variable.

i recommend using function handle combining them.

function combine(a,b) {     var c = {};     c.stuff_from_a = a.some_info;     c.stuff_from_b = b.some_info;     return c; } 

now can perform ask.

var c = combine(a,b); 

edit:

an example involving location data:

function combine(a,b) {     var c = {};     c.position_of_a = a.coordinate_info;     c.position_of_b = b.coordinate_info;     return c; } 

or store midpoint between them:

function combine(a,b) {     var c = {};     c.midpoint = average(a.location,b.location);     return c; } 

or more generally:

function combine() {     var c = {}; // initialize      // logic combine , store info      return c; // return new object } 

edit 2

c.totalmarkers = []; (var = 0; < numberofmarkersina; i++) {     c.push(a.getmarker(i)); } (var = 0; < numberofmarkersinb; i++) {     c.push(b.getmarker(i)); } 

that pseudo-code, variable names need changed of course.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -