js的数组和json区分不清,该怎么区分呢?有什么联系吗?代码如下function setIntestineBrowser(){
var userAgent = navigator.userAgent;
var browserKeyArr = [{
name:'搜狗',
domKey:'sougou',
agentKey:'MetaSr'
},{
name:'QQ',
domKey:'qq',
agentKey:'QQBrowser'
},
{
name:'猎豹',
domKey:'liebao',
agentKey:'LBBROWSER'
},{
name:'淘宝',
domKey:'taobao',
agentKey:'TaoBrowser'
},{
name:'遨游',
domKey:'aoyou',
agentKey:'Maxthon'
}];
for(var i = 0,length = browserKeyArr.length; i < length ; i++){
var pattern = new RegExp(browserKeyArr[i].agentKey);
if(pattern.test(userAgent)){
$('.collection-menu ul li[data-v=' + browserKeyArr[i].domKey + ']').click();
return ;
}
}
}browserKeyArr 是json还是数组?
添加回答
举报
0/150
提交
取消