jquery - How to add a collection in Javascript objects -
hello creating 2 dimensional array in javascript. object looks this.
totalcells = [ linenumber = 0, cells = [] ]; how add together array ?
can totalcells.push(1, ['a', 'b', 'c']);
but throws me error : cells not defined
you can't you're trying. if want keys in array utilize object. can this:
var totalcells = { linenumber: 0, cells: [] }; // logic... totalcells.linenumber = 1; totalcells.cells = ['a', 'b', 'c']; alternatively, have array of objects ties cells straight multiple linenumbers:
var totalcells = []; // logic... totalcells.push({ linenumber: 1, cells: ['a', 'b', 'c'] }); totalcells.push({ linenumber: 2, cells: ['x', 'y', 'z'] }); javascript jquery arrays
No comments:
Post a Comment