Using a regular array I am able to grab the image src from an array using shift() and pop(); I would like to do the same thing using an associative array to add a name and id.
Single Array
var products = ['product1.jpg'];
$('#products').append('<img src="' + products.shift() + '">');
Associative Array
var products = [{id:'1',name:'product 1',image:'product1.jpg'}];
$('#products').append('<img id="' + products.shift() + '" name="' + products.shift() + '" src="' + products.shift() + '">');
This line:
var products = [{id:'1',name:'product 1',image:'product1.jpg'}];declares an array with a single value inside. The single value is an object with the propertiesid,name, andimage. When you callshifton the array, the value returned will be this object.