js中indexof是否能判断字符串数组

js中indexof是否能判断字符串数组
2025-05-09 08:39:59
推荐回答(3个)
回答1:

一、可以判断。indexOf()方法可返回某个指定的字符串值在字符串中首次出现的位置。

二、语法
stringObject.indexOf(searchvalue,fromindex)
1)searchvalue :规定需检索的字符串值。
2)fromindex : 规定在字符串中开始检索的位置.它的合法取值是0到stringObject.length-1。如省略该参数,则将从字符串的首字符开始检索。

回答2:

可以的哦
var vm = LayoutRoot. DataContext as MainViewModel;
if (vm != null)
{
int count = dtgRoot. Items .Count ;
for (int i = count ; i < count + 30; i ++)
{
vm .DataItems . Add(
new DataItem ()
{
Item1 = i . ToString(),
Item2 = i . ToString() + i .ToString ()
});
}
}

回答3:

var vm = LayoutRoot. DataContext as MainViewModel;
if (vm != null)
{
int count = dtgRoot. Items .Count ;
for (int i = count ; i < count + 30; i ++)
{
vm .DataItems . Add(
new DataItem ()
{
Item1 = i . ToString(),
Item2 = i . ToString() + i .ToString ()
});
}
}