草庐IT

call_me_virtual

全部标签

javascript - 为什么你会在 Observable 函数上调用 .call() ?

我是Angular的相对初学者,我正在努力理解我从ng-bootstrap项目中阅读的一些源代码。Thesourcecodecanbefoundhere.我对ngOnInit中的代码感到很困惑:ngOnInit():void{constinputValues$=_do.call(this._valueChanges,value=>{this._userInput=value;if(this.editable){this._onChange(value);}});constresults$=letProto.call(inputValues$,this.ngbTypeahead);con

javascript - 未捕获的类型错误 : Cannot call method 'on' of undefined - Backbone. js

我的应用程序出现错误,不知道为什么。UncaughtTypeError:Cannotcallmethod'on'ofundefined它发生在我的CollectionView上,遵循代码:App.WorkoutsView=Backbone.View.extend({initialize:function(){this.collection.on('add',this.addOne,this);this.collection.on('reset',this.addAll,this);},render:function(){this.addAll();returnthis;},addAll

javascript - 在 javascript 中复制 python 的 __call__?

我想使用模块模式不复制实例化一个可调用类。以下是我对此的最佳尝试。但是,它使用了我不确定的__proto__。这可以在没有__proto__的情况下完成吗?functionclasscallable(cls){/**Replicatethe__call__magicmethodofpythonandletclassinstances*becallable.*/varnew_cls=function(){varobj=Object.create(cls.prototype);//createcallable//weusefunc.__call__becausecallmightbedef

javascript - Jade : load external javascript and call function

我正在学习Express/Node/Jade,现在我想在Jade文件中包含一个来自公共(public)文件夹的javascript文件,只用于该页面。例如,在jade文件中我输入:script(src='/javascripts/test.js')在test.js里面我有一个函数functioncheck_test(){return"It'sworking!"}然后我尝试通过以下方式调用Jade中的函数-vartest_response=check_test()比我得到的错误说“undefinedisnotafunction”和test.js根本没有加载。显然Jade不会加载文件,它们

javascript - IIFE 和 call 的区别

有区别吗:(function(){}).call(this);和(function(){})();或varMODULE={};(function(){this.hello='world'}).call(MODULE);和varMODULE={};(function(m){m.hello='world'})(MODULE);编译javascript时经常看到第一种情况。他们都将创建一个范围并做好他们的命名空间工作。有什么区别还是只是口味问题。编辑:为什么编译后的javascript会调用IIFE? 最佳答案 (function(){}

javascript - 将数组缓冲区转换为字符串 : Maximum call stack size exceeded

这是我的代码。varxhr=newXMLHttpRequest();xhr.open('GET',window.location.href,true);xhr.responseType="arraybuffer";xhr.onload=function(event){debugger;console.log("covertingarraybuffertostring");alert(String.fromCharCode.apply(null,newUint8Array(this.response)));};xhr.send();该请求是针对大小约为3MB的PDFURL发出的。我读过几

javascript - 未捕获的 RangeError : Maximum call stack size exceeded, JavaScript

我有一个问题open:function($type){//Somecodedocument.getElementById($type).addEventListener("click",l.close($type),false);},close:function($type){//Thereissomecodetoodocument.getElementById($type).removeEventListener("click",l.close($type),false);//^Recursion&UncaughtRangeError:Maximumcallstacksizeexce

设置原型(prototype)时Javascript继承: calling Object.创建

我正在学习面向对象的Javascript的某些方面。我遇到了这个片段varPerson=function(firstName,lastName){this.lastName=lastName;this.firstName=firstName;};Object.defineProperties(Person.prototype,{sayHi:{value:function(){return"Himynameis"+this.firstName;}},fullName:{get:function(){returnthis.firstName+""+this.lastName;}}});va

javascript - chain call 和 apply 在一起是什么意思?

我在jsGarden中看到这段代码,我无法理解将call和apply链接在一起的意义。两者都将使用给定的上下文对象执行函数,为什么它可以链接起来?functionFoo(){}Foo.prototype.method=function(a,b,c){console.log(this,a,b,c);};//Createanunboundversionof"method"//Ittakestheparameters:this,arg1,arg2...argNFoo.method=function(){//Result:Foo.prototype.method.call(this,arg1,

javascript - $.proxy 和原生js 'call'/'apply' 有什么区别?

我相信它们都允许您控制“this”的值,但除此之外,我有点不清楚,Google/SO到目前为止没有太大帮助。任何澄清表示赞赏。我确实找到了这个,但我怀疑它是否说明了整个故事:"WhenIfirstlearnedaboutjQuery'sproxy()method,Ithoughtitwasalittlesilly;afterall,Javascriptalreadyhascall()andapply()methodsforchangingexecutioncontext.But,onceyourealizethatjQuery'sproxy()methodallowsyoutoeasi