我有一个 javascript 数组
var array=["83487","83488","83489","83490","83491"];
我想得到这个数组的计数我怎样才能得到这里的计数是 5。
我有一个 javascript 数组
var array=["83487","83488","83489","83490","83491"];
我想得到这个数组的计数我怎样才能得到这里的计数是 5。
array.length;
或者
array["length"];
您可以使用该length
属性:
var array=["83487","83488","83489","83490","83491"];
alert(array.length);
<script>
function myFunction()
{
var sample = ["83487","83488","83489","83490","83491"];
alert(sample.length);
}
</script>
使用数组长度;它将返回数组中的元素数