JavaScript基础----29JS内置对象-Array数组对象

时间:2021-10-20 22:06:38
<!DOCTYPE html>
<!--JS内置对象-Array数组对象-->
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<!--数组合并-->
<script>
var a =["zhaihoahoa","111"]
var b =["222","3333"]
var c = a.concat(b);
document.write(c+"<br/>");
</script>
<!--排序,默认是升序-->
<script>
var a =["1","2","3","4","5"]
document.write(a.sort(function(a,b){
// return a-b;//升序
return b-a;//降序

})+"<br/>");
</script>

<!--追加-->
<script>
var a =["1","2","3","4","5"]
a.push("c")
document.write(a+"<br/>");
</script>

<!--翻转-->
<script>
var a =["c","b","a"]
document.write(a.reverse()+"<br/>");
</script>




</body>

</html>

JavaScript基础----29JS内置对象-Array数组对象