James Hammond
James Hammond

Reputation: 40

Unknown array notation javascript

I've come across the following code, I'm having trouble getting my head around it.

selCOption2[i, 'labelname'] = selOption2Arr[i];

a larger excerpt

var selCOption2 = [];
    var stringContent = '';


    jQuery('#txtTypes').attr("value", selOption1);

    for(var i=0; i<selOption2Arr.length; i++) {
      if(selOption2Arr[i] != 'Plain' || selOption2Arr[i] != 'plain') {
        selCOption2[i, 'labelname'] = selOption2Arr[i];
        selCOption2[i, 'keyname'] = keyname+"_"+selOption2Arr[i].toLowerCase()+"_"+selOption3Arr[0].toLowerCase();
        for(var ifm = 0; ifm < proJsonDetails.images.length; ifm++) {   
          if(proJsonDetails.images[ifm].indexOf(selCOption2[i, 'keyname']) > 0) {
            selCOption2[i, 'image'] = proJsonDetails.images[ifm];
          }
        }
      }
    }

Upvotes: 0

Views: 62

Answers (1)

Quentin
Quentin

Reputation: 943615

See a reduced test case:

var a = [ 'x', 'y', 'z' ];
var o = {};
var i = 1;
o[i, 'labelname'] = a[i];
console.log(o);

which gives:

{ labelname: 'y' }

The , operator evaluates as whatever is on the right hand side of it.

There doesn't appear to be any point in having i, in that code.

Upvotes: 4

Related Questions