我想返回JSON if else statetment true,但它不会返回任何内容...返回输入工作正常,但是返回原始播放列表而不是..我做错了什么? ..
这是我的源代码..
function shuffle(playlist) {
var orgplaylist = (<?php echo readmp3();?>);
console.log(orgplaylist);
console.log(playlist);
var input = playlist;
console.log(input);
if (JSON.stringify(orgplaylist) == JSON.stringify(playlist)) {
$(".random img").attr('src', 'img/loop.png');
// for (var i = input.length-1; i >=0; i--) {
for (var i = 0; i < playlist.length; i++) {
var randomIndex = Math.floor(Math.random() * (i + 1));
var itemAtIndex = input[randomIndex];
input[randomIndex] = input[i];
input[i] = itemAtIndex;
}
return input;
} else {
$(".random img").attr('src', 'img/loopsilver.png');
console.log(orgplaylist);
return orgplaylist;
}
}