我如何找到我的数组的长度 [英] how can i find the length of my array
本文介绍了我如何找到我的数组的长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
toencode: function ()
{
var xml = '';
var i = 1;
for (var p in this.pl)
{
xml += p + '=' + this.pl[p];
if(i < this.pl.length)
{
xml += '&';
}
i++;
}
return xml;
}
当我的调试器此时位于this.pl.length时,它表明长度是不确定的.
但我在pl中有3个参数.
并且如果条件将不执行.
有人可以帮我吗?
when my debugger come at this.pl.length at this point it shows that length is undefined.
but i have 3 parameter in pl.
and if condition is not going to execute.
can anyone help out me?
推荐答案
使用length
属性.
示例(取自 http://www.w3schools.com/jsref/jsref_length_array.asp [ ^ ])
Use thelength
property.
Example (taken from http://www.w3schools.com/jsref/jsref_length_array.asp[^])
<script type="text/javascript">
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.write("Original length: " + fruits.length);
document.write("<br />");
fruits.length=5;
document.write("New length: " + fruits.length);
</script>
这篇关于我如何找到我的数组的长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文