亚洲欧洲视频,三男玩一女摸吃奶,久久久久久久片,精品中文一区二区三区,美女在线国产,国产有码视频,亚洲激情五月

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

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

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

	            onSelect: function(record){

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

aa

如上圖所示,AllowedGrantTypes中明明存在granttype項(xiàng),但是返回FALSE。


下拉加載更多評(píng)論
最新評(píng)論
暫無(wú)!