Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery获取两个数组的差异_Javascript_Jquery_Arrays - Fatal编程技术网

Javascript jquery获取两个数组的差异

Javascript jquery获取两个数组的差异,javascript,jquery,arrays,Javascript,Jquery,Arrays,我有两个javascript数组: var lastWeek=["mofakkarul2013innovation", "basu2013monitoring", "petrov2013applying", "truong2013impact", "truong2013reduction", "laefer2013planning", "aksoy2013relative", "dormer2013carbon", "o2008plenary", "pakrashi164review", "zh

我有两个javascript数组:

var lastWeek=["mofakkarul2013innovation", "basu2013monitoring", "petrov2013applying", "truong2013impact", "truong2013reduction", "laefer2013planning", "aksoy2013relative", "dormer2013carbon", "o2008plenary", "pakrashi164review", "zhao2013identification", "carey2013investigating", "jacob2013icwim", "ferreira2013life", "ferreira2013life", "cottercan", "doyleoptimal", "conlon2013anatomy", "cottercan", "doyleoptimal", "conlon2013anatomy", "golsdorfgreen", "golsdorfgreen", "hochstrasserneeded", "dieterich2013greenhouse", "hassanzadeh2013identification", "nedovic2013planning", "parnellbayesian", "fennell2013simulating", "saunders2013land", "nichonchubhair2013greenhouse", "saunders2013impact", "gioria2013biological", "gauthier2013genetic", "colman2013ventbase", "yearsley2013effect", "boots2013linking", "balter2013contrasting", "roarty2013permanent", "teresa2013beef", "andriuzzi2013drilosphere", "hochstrasserneeded", "dieterich2013greenhouse", "hochstrasserneeded", "dieterich2013greenhouse", "hochstrasserneeded", "dieterich2013greenhouse", "georgiopoulou2013basement", "benetti2013late", "georgiopoulou2013critical", "parnellbayesian", "fennell2013simulating", "saunders2013land", "nichonchubhair2013greenhouse", "saunders2013impact", "gioria2013biological", "balme2013geomorphology", "courtney2013statistical", "courtney2013statistical", "tuffy2013rotate", "page2013three", "tuffy2013rotate", "page2013three", "mcdermottfrontiers", "deininger2013investigating", "comas2013impacts", "convery2013european", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "mcnamara2013experimental", "courtney2013statistical", "courtney2013high", "georgiopoulou2013basement", "benetti2013late", "georgiopoulou2013critical", "vogfjord2013extending", "jonsdottir2013coda", "ying2013time", "ferreira2013life", "rafieetwo", "banner2013unexpected", "rafiee2013numerical", "viotti2013emergence", "stefanakis2013can", "carbone2013extreme", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "murphy2013ethics", "mcnamara2013experimental", "georgiopoulou2013basement", "georgiopoulou2013basement", "cooper2013mode", "carolan2013effect", "tukovic2013finite", "carolan2013arbitrary", "kanyanta2013bio", "mohan2013effect", "walter2013detachment", "doyle2013developing", "fennell2013simulating", "saunders2013land", "nichonchubhair2013greenhouse", "saunders2013impact", "gioria2013biological", "vogfjord2013extending", "jonsdottir2013coda", "ying2013time", "courtney2013statistical", "schopfer2013three", "schopfer2013failure", "aksoy2013relative", "mcdermottfrontiers", "deininger2013investigating", "comas2013impacts", "rafieetwo", "banner2013unexpected", "rafiee2013numerical", "viotti2013emergence", "stefanakis2013can", "carbone2013extreme", "qi2013investigations", "li2013investigation", "liu2013review", "liu2013digital", "li2013k", "guo2013analysis", "sabol2013extracting", "sabol2013extracting", "zhao2013unitary", "callan2013crisis", "holohan2013stress", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "georgiopoulou2013basement", "georgiopoulou2013basement", "schopfer2013three", "schopfer2013failure", "mofakkarul2013innovation", "fennell2013simulating", "saunders2013land", "nichonchubhair2013greenhouse", "saunders2013impact", "gioria2013biological", "mcainsh2013measurement", "mcainsh2013measurement", "ali2013identification", "ali2013brassinosteroid", "ali2013insights", "diamond2013fusarium", "reape2013commentary", "diamond2013fusarium", "hochstrasserneeded", "dieterich2013greenhouse", "schopfer2013three", "schopfer2013failure", "schopfer2013three", "schopfer2013failure", "callan2013crisis", "holohan2013stress", "callan2013crisis", "holohan2013stress", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "schopfer2013three", "schopfer2013failure", "maischberger2013expression", "liu2013hplc", "miranda2013real", "zhao2013preliminary", "zhao2013preliminary", "zhao2013preliminary", "zhao2013preliminary", "boots2013linking"]

var thisWeek=["basu2013monitoring", "gonzalez2013impact", "petrov2013applying", "truong2013impact", "truong2013reduction", "laefer2013planning", "truong2013combining", "aksoy2013relative", "dormer2013carbon", "o2008plenary", "pakrashi164review", "zhao2013identification", "carey2013investigating", "jacob2013icwim", "ferreira2013life", "convery2013european", "convery2013reflections", "kroonsixth", "wan2013bootstrapping", "o2013smart", "hynes2013towards", "o2013pervasive", "sandygulova2013study", "carr2013sixth", "dragone2013programming", "cottercan", "doyleoptimal", "conlon2013anatomy", "avino2013sovereign", "scott2013design", "igoe2013investigation", "gavin2013effect", "gavin2013base", "doherty2013pile", "golsdorfgreen", "murphy2013mortgage", "scott2013design", "hochstrasserneeded", "dieterich2013greenhouse", "hassanzadeh2013identification", "nedovic2013planning", "hassanzadeh2013identification", "nedovic2013planning", "fennell2013simulating", "prescher2013short", "saunders2013land", "nichonchubhair2013greenhouse", "saunders2013impact", "gioria2013biological", "scottisolation", "dool2013phylogeography", "kirwan2013phylomedicine", "teeling2013making", "springer2013technical", "hughes2013using", "lundy2013prey", "gauthier2013genetic", "colman2013ventbase", "yearsley2013effect", "boots2013linking", "balter2013contrasting", "roarty2013permanent", "teresa2013beef", "andriuzzi2013drilosphere", "von2013skull", "hochstrasserneeded", "dieterich2013greenhouse", "kochmannenvironmental", "salvaterraimpacts", "green2013physical", "green2013effects", "crowe2013large", "gollety2013contribution", "bolger2013hierarchical", "andriuzzi2013drilosphere", "connolly2013improved", "georgiopoulou2013basement", "benetti2013late", "georgiopoulou2013critical", "parnellbayesian", "fennell2013simulating", "prescher2013short", "saunders2013land", "nichonchubhair2013greenhouse", "saunders2013impact", "gioria2013biological", "balme2013geomorphology", "ramsdale2013sinuous", "courtney2013statistical", "courtney2013high", "scott2013design", "tuffy2013rotate", "page2013three", "brooks2013production", "mcdermottfrontiers", "deininger2013investigating", "comas2013impacts", "comas2013impacts", "warren2013archaeological", "convery2013european", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "mcnamara2013experimental", "courtney2013statistical", "courtney2013high", "georgiopoulou2013basement", "benetti2013late", "georgiopoulou2013critical", "vogfjord2013extending", "jonsdottir2013coda", "ying2013time", "ferreira2013life", "ferreira2013life", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "murphy2013ethics", "mcnamara2013experimental", "georgiopoulou2013basement", "georgiopoulou2013basement", "cooper2013mode", "carolan2013effect", "tukovic2013finite", "carolan2013arbitrary", "kanyanta2013bio", "mohan2013effect", "walter2013detachment", "doyle2013developing", "fennell2013simulating", "prescher2013short", "saunders2013land", "nichonchubhair2013greenhouse", "saunders2013impact", "gioria2013biological", "vogfjord2013extending", "jonsdottir2013coda", "ying2013time", "doyle2013developing", "courtney2013statistical", "courtney2013high", "schopfer2013three", "schopfer2013failure", "schopfer2013three", "schopfer2013failure", "mcdermottfrontiers", "deininger2013investigating", "comas2013impacts", "comas2013impacts", "rafieetwo", "banner2013unexpected", "rafiee2013numerical", "viotti2013emergence", "stefanakis2013can", "carbone2013extreme", "dutykh2013use", "qi2013investigations", "li2013investigation", "liu2013review", "liu2013digital", "li2013k", "guo2013analysis", "sabol2013extracting", "sabol2013extracting", "zhao2013unitary", "ryle2013calibration", "callan2013crisis", "holohan2013stress", "igoe2013investigation", "gavin2013effect", "gavin2013base", "doherty2013pile", "lynch2013utilisation", "everard2013evaluation", "o2013feasibility", "devlin2013fuel", "wolff2013practical", "sweeney2013development", "mcdonnell2013photo", "omara2013anaerobic", "mcdonnell2013fabrication", "goodbody2013regional", "narancic2013highly", "molloy2013engineering", "babu2013current", "casey2013effect", "brooks2013production", "o2013anti", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "georgiopoulou2013basement", "georgiopoulou2013basement", "schopfer2013three", "schopfer2013failure", "mofakkarul2013innovation", "fennell2013simulating", "prescher2013short", "saunders2013land", "nichonchubhair2013greenhouse", "saunders2013impact", "gioria2013biological", "mcainsh2013measurement", "brooks2013production", "ali2013identification", "ali2013brassinosteroid", "ali2013insights", "diamond2013fusarium", "mullins2013method", "reape2013commentary", "diamond2013fusarium", "hochstrasserneeded", "dieterich2013greenhouse", "schopfer2013three", "schopfer2013failure", "kavanagh2013microbial", "amadio2013filamentous", "hamza2013isolation", "robertson2013synthesis", "callan2013crisis", "holohan2013stress", "feeley2013regional", "o2013performance", "nasr2013derivation", "feeley2013regional", "ahilan2013bankfull", "neil2013modelling", "o2013parameter", "kochmannenvironmental", "salvaterraimpacts", "green2013physical", "green2013effects", "crowe2013large", "gollety2013contribution", "schopfer2013three", "schopfer2013failure", "maischberger2013expression", "liu2013hplc", "miranda2013real", "zhao2013preliminary", "kavanagh2013microbial", "amadio2013filamentous", "hamza2013isolation", "robertson2013synthesis", "brooks2013production", "narancic2013highly", "molloy2013engineering", "babu2013current", "casey2013effect", "brooks2013production", "o2013anti", "boots2013linking"]
“上周”是上周的论文列表“本周”是本周的论文列表

如何在jQuery中获得新的论文?(即不包括上周发表的所有论文)

我试过:

var diff=$(thisWeek).not(lastWeek).get()
但是这给了我一个错误的差异——差异中没有一篇论文在本周的列表中:它们都在上周的差异中;(

非常感谢,来自

应该是

var diff=$(lastWeek).not(thisWeek).get();
您做得不错,但是为什么在jQuery中使用不同的变量呢

编辑:如果上面没有工作(顺便说一句,我认为这是正确的),那么创建一个新数组

var _diff = new Array();
然后像这样做:

_diff = jQuery.grep(lastWeek, function (whatsNew) {
     return jQuery.inArray(whatsNew, thisWeek) < 0;
});
\u diff=jQuery.grep(上周,函数(whatsNew){
返回jQuery.inArray(whatsNew,thisWeek)<0;
});
应该是

var diff=$(lastWeek).not(thisWeek).get();
您做得不错,但是为什么在jQuery中使用不同的变量呢

编辑:如果上面没有工作(顺便说一句,我认为这是正确的),那么创建一个新数组

var _diff = new Array();
然后像这样做:

_diff = jQuery.grep(lastWeek, function (whatsNew) {
     return jQuery.inArray(whatsNew, thisWeek) < 0;
});
\u diff=jQuery.grep(上周,函数(whatsNew){
返回jQuery.inArray(whatsNew,thisWeek)<0;
});

可能重复可能重复抱歉,我更改了变量名。Fixed post.抱歉,我更改了变量名。Fixed post.diff现在只包含“lastWeek”中显示的变量。我只需要“thisWeek”中的变量。然后您需要执行其他循环,循环
thisWeek
并检查
lastWeek
diff现在只包含“lastWeek”中出现的变量。我只需要“thisWeek”中的变量。然后您需要执行其他循环,循环
thisWeek
并检查
lastWeek