- :
var obj = {
'song1': 'http://...1',
'song2': 'http://...2',
'song3': 'http://...3',
'song4': 'http://...4',
'song5': 'http://...5',
'song6': 'http://...6',
}, tempArr = [], len, rand, song;
for ( var key in obj )
if ( obj.hasOwnProperty(key) )
tempArr.push( obj[key] );
len = tempArr.length;
rand = Math.floor( Math.random() * len );
song = tempArr[rand];
document.write(song);
, , , , :
var songs = [
{title: 'Song1', url: 'http://...1.mp3'},
{title: 'Song2', url: 'http://...2.mp3'},
{title: 'Song3', url: 'http://...3.mp3'}
];