var arr= [1,2,3,4]console.log(typeof(arr))console.log(arr[0]) for (var i = 0; i < arr.length;i++){console.log("arr[%d] = %d",i,arr[i])} //数值查找数组的位置var res = arr.indexof(4) ============数组创建================
var arr1= new Array()console.log(arr1) var arr1= new Array(1,2,3,"savl")console.log (arr1) var arr1= new Array(10)console.log(arr1) ============排序==================
var arr = new Array(4)arr[0]=2arr[1]=1arr[2]=3arr[3]= 5arr[4]=6 arr.sort() console.log(arr)
原文地址:https://www.cnblogs.com/jeco-li/p/10117025.html
时间: 2024-10-08 21:05:23