请问这一串是什么意思
```html
$(function() {
getCatList();
getPlayList();
})
function getCatList() {
$.get(`./json/catList.json`, {}, function(data) {
var sub = data.sub;
var categories = data.categories;
for(var index in categories){
$('#catList').append(`
<li class="list-group-item row">
<div class="col-xs-2 col-sm-1 text-right categorie">${categories[index]}</div>
<ul class="nav nav-pills col-xs-10 col-sm-10 text-justify">
<li role="presentation" class="active">
<a href="#">全部</a>
</li>
</ul>
</li>
`);
$(sub).each(function(i,subItem){
if(subItem.category==index){
$("#catList .nav").eq(index).append(`
<li role="presentation">
<a href="#">${subItem.name}</a>
</li>
`)
}
})
//$("#catList .nav").eq(index).find("li:first-child").addClass("active")
}
}, 'json')
}
function getPlayList(){
$.get(`./json/playList.json`, {}, function(data) {
var playlists = data.playlists;
console.log(playlists)
$(playlists).each(function(index, item) {
var playCount = formatPlayCount(item.playCount);
$('#playlists').append(`
<div class="col-xs-6 col-sm-3 col-md-2">
<a class="thumbnail">
<img src="${item.coverImgUrl}" class="img-responsive" alt="...">
<div class="caption">
<h5>${item.name}</h5>
<p class="playCount">播放量:${playCount}</p>
</div>
</a>
</div>
`);
})
}, 'json');
}
function formatPlayCount(playCount) {
var playCountStr = playCount;
if (playCount > 100000000) {
playCountStr = (playCount / 100000000).toFixed(1) + "亿"
} else if (playCount > 10000) {
playCountStr = (playCount / 10000).toFixed(1) + "万"
}
return playCountStr;
}
```
具体要看你的json是什么内容,以及你的网页,大致来说,这是使用 jQuery 用ajax的方式下载2个json,根据json的内容动态向网页添加歌曲、歌曲评价、图片之类的东西。
方法一:递归
let cloneObj = function(obj) {
let str,
newobj = obj.constructor === Array ? [] : {};
if (typeof obj !== "object") {
return;
} else if (window.JSON) {
(str = JSON.stringify(obj)), //系列化对象
(newobj = JSON.parse(str)); //还原
} else {
for (var i in obj) {
newobj[i] = typeof obj[i] === "object" ? cloneObj(obj[i]) : obj[i];
}
}
return newobj;
};
let newArr = cloneObj(oldArr);
方法二:通过 JSON 解析解决
let newArr = JSON.parse(JSON.stringify(oldArr));