{title:'Alan', hasChild:true},
{title:'Alice', hasDetail:true},
{title:'Amos'},
{title:'Alonzo'},
{title:'Brad'},
{title:'Brent'},
{title:'Billy'},
{title:'Brenda'},
{title:'Callie'},
{title:'Cassie'},
{title:'Chris'},
如何迭代数组并找出每个元素的索引和第一个字符。
最佳答案
迭代很容易:
for (var i = 0; i < yourArrayName.length; i++) {
yourArrayName[i].title.charAt(0) // This is the first letter.
}
关于javascript - 迭代数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5930806/