国产aaa免费视频国产,日韩一区二区不卡中文字幕,日产精品一二三四区国产,69频道,精品亚洲成a人片在线观看,伊人福利视频,欧美线在线精品观看视频

威勢網(wǎng)絡(luò),為您的企業(yè)和團隊注入互聯(lián)網(wǎng)活力!
服務(wù)熱線:138-9741-0341

js 對象、數(shù)組的定義,及數(shù)組元素查找是否包含子項

發(fā)布日期:2022/10/11 作者: 瀏覽:660
            var AllowedGrantTypes = []; //在循環(huán)體外面定義一個全局?jǐn)?shù)組對象,等一下往這里面PUSH進內(nèi)容
.... 省略若干行

	            onSelect: function(record){

                    var GrantType={};  //定義一個子項,要push進數(shù)組中
                    GrantType.name=record.name;  //添加字段
                    GrantType.id=record.id;  //添加字段
                    console.log("+=:"+record.name + record.id); 
                    //if (AllowedGrantTypes.indexOf(GrantType) < 0) {   //這樣子查找是沒有結(jié)果的,就結(jié)果存在也會返回-1
                    //    AllowedGrantTypes.push(GrantType);
                    //}
                    if (AllowedGrantTypes.findIndex(item=>item.id==GrantType.id && item.name==GrantType.name) < 0) {  //用這種方法去查找比較保險,若不存在,則push
                        AllowedGrantTypes.push(GrantType);
                    }
                    
                    console.log("length=:"+AllowedGrantTypes.length); 
                },

aa

如上圖所示,AllowedGrantTypes中明明存在granttype項,但是返回FALSE。


下拉加載更多評論
最新評論
暫無!