Sunday, February 12, 2012

Generate jquery array so I can use ++arrayname[i]; [closed]


I want to generate a basic array and declare it with a 'n' number of elements in jquery. I want to initialize each value of the array with 0 and I want to be able to call increment each value of the array. How can I do it?




++arrayname[i];

1 comment:

  1. If I understand, you need something like that:


    To initialize:

    $.each(arrayname, function(idx, elt) {
    arrayname[idx]=0; // **EDIT**
    });

    To increment:

    $.each(arrayname, function(idx, elt) {
    arrayname[idx]++; // **EDIT**
    });

    ReplyDelete