草庐IT

Call-time

全部标签

javascript - Backbone : Call an extended view's overridden render() function

我有一个WorkoutExerciseRowView,它扩展了ExerciseRowView。渲染函数非常相似,除了WorkoutExerciseRowView必须向ExerciseRowView的渲染添加一些参数。如何在WorkoutExerciseRowView的渲染函数中调用ExerciseRowView的渲染函数?varWorkoutExerciseRowView=ExerciseRowView.extend({render:function(){//returnthis.constructor.render({//doesn'tworkreturnthis.render({/

javascript - this.someFunction.call(this, param); 的目的是什么?

我在很多地方都遇到过一些具有这种模式的代码:this.someFunction.call(this,param);但在我看来这只是一种更冗长的打字方式this.someFunction(param)该模式有时会出现在作为回调提供的函数中。如果相关的话,它恰好使用了Backbone。像这样:Backbone.View.extend({//otherstuff...someFunction:function(param){//...},anotherFunction:function(){this.collection.on("some_event",function(){this.som

javascript - Ionic 2 构建开发失败 : Maximum call stack size exceeded

我无法构建我的ionic2应用程序。更改文件后服务有效。在ionic服务上,我收到以下错误消息:[07:36:10]ionic-app-scripts1.0.0[07:36:10]watchstarted...[07:36:10]builddevstarted...[07:36:10]cleanstarted...[07:36:10]cleanfinishedin1ms[07:36:10]copystarted...[07:36:10]transpilestarted...[07:36:15]builddevfailed:Maximumcallstacksizeexceeded[07:

javascript - "Call stack"和 JavaScript 中的 "Execution context stack"一样吗?

我经常在很多文章中看到“调用堆栈”。像这样:https://hackernoon.com/understanding-js-the-event-loop-959beae3ac40#ec22但是在ECMAScript文档中找不到“调用堆栈”。“调用堆栈”是否与“Executioncontextstack”相同? 最佳答案 СallStack和ExecutionStack是同一事物的不同名称。它是一个LIFO堆栈,用于存储在代码执行期间创建的执行上下文。维基百科说:“这种堆栈也称为执行堆栈、程序堆栈、控制堆栈、运行-时间堆栈,或机器堆栈

javascript - Angular 和 Observable : how to avoid multiple requests to API within a given time

我在Angular4应用程序中有类似的东西(为了示例,我删除了代码)@Injectable()exportclassSomeService{constructor(privatehttp:Http){}get(id:number){returnthis.http.get('http://somedomain/somemodel/${id}.json');}}一些组件使用它来进行API调用。constructor(privatesomeService:SomeService){}...someMethod(){//codehere...this.someService.get(2).su

javascript - 如何解决 “cannot call method … of undefined” 错误?

functioncalcRoute(){varstart=document.getElementById("start_").value;varend=document.getElementById("end_").value;varrequest={origin:start,destination:end,travelMode:google.maps.TravelMode.DRIVING};directionsService.route(request,function(response,status){if(status==google.maps.DirectionsStatus.

javascript - 如何使用 call/apply 检查函数是否被调用

functionfoo(){console.log('foo',this);}foo();foo.call({bar:1});foo.apply([{bar:1}]);有什么方法可以知道foo()是使用普通调用还是call/apply调用的?http://jsfiddle.net/H4Awm/1/ 最佳答案 没有。您无法检测函数是从call/apply调用还是正常调用。它们不是魔法生物,它们所做的只是设置参数和this值。有一个subtledifference当涉及到未定义/未声明的值时,仅此而已。全部.apply和.call在ES

javascript - 除了执行 Object.prototype.hasOwnProperty.call(obj, key) 是否有 ES6+ 替代方案?

检查对象是否具有特定键的最可靠方法是:Object.prototype.hasOwnProperty.call(obj,key)这提供了一定的保证:如果key是obj的direct属性,它只会评估为true,即使obj没有通常的Object作为其原型(prototype)(例如,如果它是用constobj=Object.create创建的)(null)).但这是一口。在ES6或更高版本中是否有任何新的语法/方法(包括polyfillable或Babel可编译的“建议”)提供相同的保证,但以更好、更易读的方式? 最佳答案 我不知道这有

JavaScript 装饰器模式。错误 : Maximum call stack size exceeded

这是装饰器模式的一个工作示例:classDummy{run(){console.log('run');}}functionget(){letinstance=newDummy();instance.run=((func)=>{returnfunction(){func();console.log('decoratorrun');}})(instance.run);returninstance;}letobj=get();obj.run();但是,如果我们将get函数更改为:functionget(){letinstance=newDummy();instance.run=functio

javascript - 你如何引用 Array.prototype.slice.call()?

我正在编写一个脚本,其中我需要在许多不同的地方克隆数组。因此,我想执行以下操作来模拟克隆功能:varclone=[].slice.call;vararr1=[1,2,3,4,5,6,7,8,9,10];vararr2=clone(arr1,0);不幸的是,上面的代码导致:TypeError:objectisnotafunction。我意识到有很多功能可以进行深度克隆和浅拷贝,但我只想使用内置方法。有趣的是,以下确实有效:varclone=[].slice;vararr1=[1,2,3,4,5,6,7,8,9,10];vararr2=clone.call(arr1,0);有谁知道为什么第