<html>
<head>
<title>数组</title>
<meta charset="UTF-8"/>
</head>
<body>
<script type="text/javascript">
function compare(vaule1,value2){
if(value1<value2){
return -1;}
else if(value1>value2){
return 1;}
else{
return 0;}
}
var values=[0,1,5,10,15];
values.sort(compare);
alert(values);
</script>
</body>
</html>
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
-兄弟你拼错单词了。
一个是vaule1, 一个是value1
函数参数拼写错误,还有浏览器调试,要学会使用F12查看浏览器开发者工具console选项卡的错误提示
可能的两个原因:
上述答案所描述的拼写错误
script脚本是理应放在html文件的head部分的.修正后参考: