代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
<script>
// ### 1. 字符串"要考试了,要好好复习,不要挂科",取满里面5个不同的字符,逗号能一个字符
var str = "要考试了,要好好复习,不要挂科";
var han = {
handle: function (arr = []) {
var shuzu = str[Math.floor(Math.random() * (str.length))];
if (arr.length < 5) {
if (arr.indexOf(shuzu) == -1) {
arr.push(shuzu);
}
this.handle(arr);
}
}
}
var arr = [];
han.handle(arr);
console.log(arr);
// 取出student,按date 进行升序排列;
var stu = {
"data": {
'list': [{
'student': [
{ date: '2022 10/1', 'name': '张三', 'pid': 0 },
{ date: 1665648330145, 'name': '张三三', 'pid': 1 },
{ date: 1655648330145,name: '李四', 'pid': 2 },
{ date: '2022 10/3', 'name': '李四四', 'pid': 3 },
{ date: '2020 10/3', 'name': '王五', 'pid': 3 },
]
}]
}
}
var student = stu.data.list[0].student
console.log(student);
student.sort(function (a, b) {
var date1 = new Date(a.date);
var date2 = new Date(b.date);
return date1 - date2
});
console.log(student);
</script>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。