草庐IT

filter-name

全部标签

JavaScript filter() 方法混淆

作为LearnJavaScriptProperly的一部分,我正在研究JavaScript:权威指南,我在推理第7章数组方法部分的filter()方法时遇到了麻烦。这是提供的示例:Thefilter()methodreturnsanarraycontainingasubsetoftheelementsofthearrayonwhichitisinvoked.Thefunctionyoupasstoitshouldbepredicate:afunctionthatreturnstrueorfalse.ThepredicateisinvokedjustasforforEach()andma

javascript - Array.filter 无法正常工作

我有一个数组,我想从中删除一条记录我已经使用了Array.filter()但它返回的是相同的数组。我的代码:varurl=window.location.pathname,orderId=url.split('/').slice(-2)[0];varCart=JSON.parse(localStorage.getItem('Cart'));newCart=Cart.filter(function(item){if(parseInt(item.orderId)==parseInt(orderId)){return{};}else{returnitem;}});localStorage.s

javascript - arguments.callee.toString() 和 arguments.callee.name 不返回函数名

我正在尝试获取当前正在运行的函数的名称。根据我的阅读,这应该可以使用:(arguments.callee.toString()).match(/function\s+(\[^\s\(]+)/)但是,当我在Firefox和Safari(Mac上的最新版本)中运行时,不会返回名称。console.log(arguments.callee)返回函数的源,但不返回分配的名称。arguments.callee.name返回空字符串。我的示例代码如下:vartestobj={testfunc:function(){console.log((arguments.callee.toString()).

JavaScript 1.6 Array.map() 和 Array.filter() 不使用内置函数作为参数

这很好用:["655971","2343","343"].map(function(x){returnparseInt(x)})//[655971,2343,343]但这不是:["655971","2343","343"].map(parseInt)//[655971,NaN,NaN]Array.filter()也是如此我在这里错过了什么? 最佳答案 这是因为map向回调函数传递的参数不仅仅是数组项。你得到:callback(item,index,array)通常你的函数会忽略它不需要的参数。但是parseInt接受一个可选的第二个

javascript - 使用 ngx-filter-pipe angular 过滤多个值

我正在使用Angular为4的ngx-filter-pipe,但我遇到了这个问题。我设法用一个值过滤,现在我试图用多个值过滤数据:这是我得到的这是我的组件:@Component({selector:'deudas-list',templateUrl:'../views/deudas-list.html',providers:[DeudaService]})exportclassDeudasListComponent{publictitulo:string;publicdeudas:Deuda[];publicuserFilter:any={mes:''};constructor(pri

javascript - Jest : Mock ES6 Module with both default and named export

我有一个带有默认导出和命名导出的ES6模块:/**/src/dependency.js**/exportfunctionutilityFunction(){returnfalse;}exportdefaultfunctionmainFunction(){return'foo';}它被第二个ES6模块使用:/**/src/myModule.js**/importmainFunction,{utilityFunction}from'./dependency';//EDIT:Fixedsyntaxerrorincodesample//exportdefaultmyModule(){expor

javascript - 使用 data-template-name 命名 Ember.js 模板

我注意到Ember.js文档解释了命名模板的方法是通过设置标签的data-template-name模板名称的值。但在Ember.js文档站点上TomDale的最新截屏视频中,他使用ID命名模板。我假设它们都是在Ember中命名模板的有效方法。为什么要使用data-template-name与id相对应? 最佳答案 虽然两者都有效,但使用data-template-name可以让您自由使用不会与您的模板名称冲突的元素ID。 关于javascript-使用data-template-nam

mongodb - filter:= bson.D {{“hello”,“world”}}}而不是使用value(world)如何传递包含该值的变量(world)

Closed.Thisquestionneedsdetailsorclarity。它当前不接受答案。想改善这个问题吗?添加详细信息,并通过editingthispost阐明问题。去年关闭。Improvethisquestion使用Go从mongodb获取特定内容时,例如:filter:=bson.D{{"hello","world"}}在这种情况下,我如何传递包含值(世界)的变量而不是传递值(世界)?username:=r.FormValue("username")filter:=bson.D{{"username",'$username'}} 最佳答案

go - 如何修复 'name' is undefined on object 错误?

关闭。这个问题需要debuggingdetails.它目前不接受答案。编辑问题以包含desiredbehavior,aspecificproblemorerror,andtheshortestcodenecessarytoreproducetheproblem.这将有助于其他人回答问题。关闭3年前。Improvethisquestion我正在使用Go向bigpanda发出API发布请求。https://docs.bigpanda.io/reference#create-plan我有以下代码,当我尝试使APIpostgettingnameisundefinedonobjecterror时

arrays - 语法错误 : unexpected name, 期待)

我在GO中有我的BST代码。我不断收到此错误消息。我正在使用记事本,我是初学者。错误在我的for循环中。在insertList函数下。typenodestruct{left*noderight*nodevalint}funcinsert(tree*node,elementint)*node{iftree==nil{tree=&node{nil,nil,element}}elseifelement>tree.val{tree.right=insert(tree.right,element)}elseifelement 最佳答案 这应该