It's logging the array, because you fed but it the array. The reason why Chrome doesn't show anything inside the array isseems empty, because you didn't populate it numerically ( which is how arrays should be populated ). If you want to alertYou can still access the name property of the first array object, then:
var albums = new Array();
var album = new Array();
album['name'] = 'This is War';
albums.push(album);
console.log(albums);
console.log(albums[0].name);
If you are just settingin JS, Any object can have properties, and arrays are objects. If you shouldhave no use for numerical ordering for the album nor any of the array methods, then use an object literal.and not an array:
var albums = [], album = {};
album['name'] = 'Test';
albums.push(album)
console.log(albums);
console.log(albums[0].name);
in JS, Any object can have properties, and arrays are objects. If you have no use for numerical ordering for the album nor any of the array methods, then use an object and not an array.
It's logging the array, because you fed it the array. The reason why Chrome doesn't show anything inside the array is because you didn't populate it numerically. If you want to alert the name property of the first array object, then:
var albums = new Array();
var album = new Array();
album['name'] = 'This is War';
albums.push(album);
console.log(albums);
console.log(albums[0].name);
If you are just setting properties, you should use an object literal.
var albums = [], album = {};
album['name'] = 'Test';
albums.push(album)
console.log(albums);
console.log(albums[0].name);
in JS, Any object can have properties, and arrays are objects. If you have no use for numerical ordering for the album nor any of the array methods, then use an object and not an array.
It's logging the array but it seems empty, because you didn't populate it numerically ( which is how arrays should be populated ). You can still access the name property of the array,
var albums = new Array();
var album = new Array();
album['name'] = 'This is War';
albums.push(album);
console.log(albums);
console.log(albums[0].name);
in JS, Any object can have properties, and arrays are objects. If you have no use for numerical ordering for the album nor any of the array methods, then use an object and not an array:
var albums = [], album = {};
album['name'] = 'Test';
albums.push(album)
console.log(albums);
console.log(albums[0].name);
It's logging the array, because you fed it the array. The reason why Chrome doesn't show anything inside the array is because you didn't populate it numerically. If you want to alert the name property of the first array object, then:
var albums = new Array();
var album = new Array();
album['name'] = 'This is War';
albums.push(album);
console.log(albums);
console.log(albums[0].name);
If you are just setting properties, you should use an object literal.
var albums = [], album = {};
album['name'] = 'Test';
albums.push(album)
console.log(albums);
console.log(albums[0].name);
in JS, Any object can have properties, and arrays are objects. If you have no use for numerical ordering for the album nor any of the array methods, then use an object and not an array.