javascript - Push array to a collection of arrays -
i'm trying push array collection of arrays i'm getting unexpected results.
var itemx = ['a','b','c']; var itemy = ['x', 'y', 'z']; var itemlist = []; itemlist.push(itemx); itemlist.push(itemy); i'm expecting this:
itemlist = [ ['a', 'b', 'c'], ['x', 'y', 'z'] ] but instead i'm getting this:
itemlist = ['a', 'b', 'c', 'x', 'y', 'z'] am missing here? appreciated. thank much.
i think working fine, probable reason might trying alert itemlist; alerts a,b,c,x,y,z.
var itemx = ['a','b','c']; var itemy = ['x', 'y', 'z']; var itemlist = []; itemlist.push(itemx); itemlist.push(itemy); alert(json.stringify(itemlist));
Comments
Post a Comment