草庐IT

filter_parameters

全部标签

javascript - ES6 : Filter data with case insensitive term

这就是我按标题值过滤一些数据的方式:data.filter(x=>x.title.includes(term))这样的数据SampleoneSampleTwoBlatwo将被“减少”为Blatwo如果我按两个过滤。但是我需要得到过滤后的结果SampleTwoBlatwo 最佳答案 您可以使用不区分大小写的正则表达式://Notethatthisassumesthatyouarecertainthat`term`contains//nocharactersthataretreatedasspecialcharactersbyaRegE

javascript - 在大数组上使用多个 '.filter' 调用是否会影响性能?

我写了这段代码来过滤一个单词数组。我为我想过滤掉的每种类型的单词编写了一个过滤函数,并将它们按顺序应用于数组:constwordArray=rawArray.filter(removeNonDomainWords).filter(removeWordsWithDigits).filter(removeWordsWithInsideNonWordChars).filter(removeEmptyWords).filter(removeSearchTerm,term).map(word=>replaceNonWordCharsFromStartAndEnd(word))如果我没记错的话,这

javascript - 未捕获的语法错误 : Setter must have exactly one formal parameter

我试图理解JS上的getter和setter,但我似乎无法通过此错误。任何人都可以提供关于为什么我会收到此错误的任何见解吗?varbook={year:2004,edition:1,getnewYear(){return"Hello,it's"+this.year;},setnewYear(y,e){this.year=y;this.edition=e;}};UncaughtSyntaxError:Settermusthaveexactlyoneformalparameter 最佳答案 当您分配setter代表的值时调用setter

Logstash filter 的插件使用

Logstashfilter的使用一句话就是通过logstash对日志进行格式化(过滤)。logstash有三个插件input(接收数据源的数据)、filer(实现数据格式化)、output(输出到目标)。Filter插件(过滤器插件)可以实现如:数据解析、删除字段、类型转换等等统称名词实现数据格式化常见的有如下几个:grok:正则匹配解析date:日期解析dissect:对字段做处理,如:重命名、删除、替换等json:安装json解析字段内容到指定字段中geoip:增加地理位置数据ruby:利用ruby代码来动态修改LogstashEventGrok插件grok是一个十分强大的logstas

javascript - 使用 .filter 比较两个数组并返回不匹配的值

我在比较两个数组的元素和过滤掉匹配值时遇到了一些问题。我只想返回未包含在wordsToRemove中的数组元素。varfullWordList=['1','2','3','4','5'];varwordsToRemove=['1','2','3'];varfilteredKeywords=fullWordList.forEach(function(fullWordListValue){wordsToRemove.filter(function(wordsToRemoveValue){returnfullWordListValue!==wordsToRemoveValue})});con

javascript - JS : Filter object array for partial matches

是否可以过滤那些与搜索字符串匹配的对象?constarr=[{title:'Justanexample'},{title:'Anotherexam'},{title:'Somethingdifferent'}]我试过了arr.filter(x=>{returnx.title===searchStr});但这只会过滤完全匹配项,但我需要找到所有部分匹配项。letsearchStr='exam'应该给我两个对象(第一个和第二个),letsearchStr='examp'应该只给我一个对象作为结果。 最佳答案 根据您的问题,我假设您还想匹

JavaScript (ES6) : Named parameters and default values

我来自Python,我真的很喜欢设置命名参数和默认值的方式——现在看来ES6允许我做类似的事情。但我不明白为什么最后一次通话中断了:fun=({first=1,last=1})=>(1*first+2*last)console.log("-----------")console.log(fun({first:1,last:2}))console.log("-----------")console.log(fun({last:1,first:2}))console.log("-----------")console.log(fun())//Breaks 最佳答

javascript - Jquery 时间选择器 : How to dynamically change parameters

我正在使用JqueryTimepicker。我有两个输入字段-接受时间。我正在根据documentation使用JqueryUI计时器$('#startTime').timepicker({'minTime':'6:00am','maxTime':'11:30pm','onSelect':function(){//changethe'minTimeparameterof#endTime我希望当第一次选择timePicker时,第二个的“minTime”参数会发生变化。基本上我正在尝试收集某些事件的开始时间和结束时间。我希望第二个输入框显示第一个输入字段(开始时间)本身的值的选项。

javascript - 在 React 中使用 $splice(来自 immutability-helper)而不是 filter 从数组中删除项目有什么优势?

我正在使用immutability-helper对状态数据进行CRUD操作,想知道我是否应该始终使用$splice来删除数据,还是可以使用filter(因为它没有破坏性)?例如,假设我有一个对象数组:todos=[{id:1,body:"eat"},{id:2,body:"drink"},{id:3,body:"sleep"},{id:4,body:"run"}]给定一个项目ID,我可以通过两种方式删除它:一个。找到它的index并使用$splice:index=todos.findIndex((t)=>{return(t.id===id)});newtodos=update(todo

javascript - 结合 angularJS 和 d3.js : Refreshing a plot after submitting new input parameters

我希望在单击输入字段中包含新值的提交按钮后,我的网络d3.js绘图将根据生成的新图进行更新通过新输入值。在下面,您可以找到我的示例代码:GenerateGraph.js该文件包含一系列函数,可根据提交输入值。然后需要在浏览器中刷新图形。functiondegree(node,list){vardeg=newArray();for(vari=0;inetwork.html!DOCTYPEhtml>graphSimulatinganetwork//gettheinputparametersforplottingangular.module("myApp",[]).directive('ne