<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <script> //array类型 /*var color = new Array(); var colors = new Array(20);//创建一个长度20的数组 var colorss = new Array("red","blue","green"); //var colors=["red","blue","green"]; console.log(colorss); console.log(colorss[0]); colorss[2]="black";//修改 colorss[3]="gray"; console.log(colorss);*/ var colorss = new Array("red","blue","green"); colorss.length=5; //alert(colorss[4]);//设置长度----undefined var colo=["red","blue"]; colo[colo.length]="green"; colo[colo.length]="black";//可以添加 console.log(colo); //检测数组方式 value=[]; if(value instanceof Array){ alert('yes'); } if(Array.isArray(value)){ } </script> </body> </html> |
|
来自: phpcoder_echo > 《js》