Javascript数组元素计数

时间:2013-07-09 07:07:35

标签: php javascript jquery

我有一个javascript数组

var array=["83487","83488","83489","83490","83491"];

我想获得此数组的Count 我该如何计算 这是5。

4 个答案:

答案 0 :(得分:3)

array.length;

array["length"];

答案 1 :(得分:0)

您可以使用length属性:

var array=["83487","83488","83489","83490","83491"];
alert(array.length);

答案 2 :(得分:0)

 <script>
 function myFunction()
 {
  var sample = ["83487","83488","83489","83490","83491"];
  alert(sample.length);
 }
 </script>

Sample

答案 3 :(得分:0)

使用array.length;它会返回数组中元素的数量