草庐IT

super-constructor

全部标签

javascript - Google 日历 API 和 Node js - "googleAuth is not a constructor"问题

我正在尝试在Node上设置Google日历API,使用出现的Node.js快速入门here完成前3个步骤并运行我的quickstart.js以检查它是否有效(我从快速入门复制并粘贴)后,我收到以下错误:“类型错误:googlAuth不是构造函数”它指的是这行代码:varauth=newgoogleAuth();googleAuth是这样声明的:vargoogleAuth=require('google-auth-library');我在网上找不到任何解决方案。完整代码在上面第三步的链接中。提前致谢,阿萨夫。 最佳答案 版本已经改变,

javascript - Constructor.prototype 不在原型(prototype)链中?

相关:Confusionaboutprotypechain,primitivesandobjects在Firebug控制台中:a=12a.constructor.prototype.isPrototypeOf(a)//prints'false'我认为这应该打印true 最佳答案 a=12创建一个原始数字,它与Number对象不太一样。出于属性访问的目的,基元被隐式转换为对象。a=12;//aisaprimitiveb=newNumber(12);//bisanobjecta.constructor.prototype.isProto

javascript - 使用 ES6 类将实例方法传递给 super

据我了解,在调用super()之前,this在构造函数中不可用。不过,在引用实例方法时,我们需要在方法前加上this前缀。那么如何将实例方法传递给super()呢?例如在Phaserframework,有一个Button类(class)。构造函数接受点击事件的回调:ConstructornewButton(game,x,y,key,callback,callbackContext,overFrame,outFrame,downFrame,upFrame)callback-ThefunctiontocallwhenthisButtonispressed.callbackContext-T

javascript - 使用 constructor.prototype 遍历原型(prototype)链

如果我可以使用obj.constructor.prototype访问对象的原型(prototype),那为什么我不能使用obj.constructor.prototype.constructor.prototype遍历原型(prototype)链还得用Object.getPrototypeOf?functionMyConstructor(){this.prop=1;}varo=newMyConstructor();console.log(o.constructor.prototype)//MyConstructorconsole.log(o.constructor.prototype.

javascript - 原型(prototype)继承。 obj->C->B->A,但 obj.constructor 是 A。为什么?

varprint=function(text){document.write(text);document.write("");}varA=function(){}A.prototype.name="A";varB=function(){}B.prototype=newA();B.prototype.name="B";varC=function(){}C.prototype=newB();C.prototype.name="C";obj=newC();print(obj.name);print(obj.constructor.prototype.name);print(obj.cons

javascript - 从子类调用父类(super class)方法 - JavaScript

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:setattributewithjavascriptsupermethod为了好玩,我正在尝试用HTML5创建一个简单的游戏。我有一个Entity类,它应该是Player类的父类(superclass)。functionEntity(x,y){this.x=x;this.y=y;this.tick=function(){//Dogenericstuff}}functionPlayer(x,y){this.parent.constructor.call(this,x,y);this.tick=function(

javascript - 继承和 TypeScript 错误 : X is not a constructor function type

我有一个父类(superclass),我希望从中继承其他两个类。下面列出了这些类(class)。当我编译时,试图继承的两个类提示父类(superclass)(给出相同的错误):“[类文件路径(在本例中为A)]不是构造函数类型”A.tsexportclassA{//privatefields...constructor(username:string,password:string,firstName:string,lastName:string,accountType:string){//initialisation}}B.tsimportA=require('./A);exportc

javascript - 当 myarray 在一个框架中时,为什么 myarray instanceof Array 和 myarray.constructor === Array 都为 false?

所以下面的代码会发出两次错误警报:window.onload=function(){alert(window.myframe.myarrayinstanceofArray);alert(window.myframe.myarray.constructor===Array);}当页面中有一个名为“myframe”的iframe包含一个名为“myarray”的数组时。如果数组被移动到主页(而不是iframe),那么代码会像预期的那样发出两次true警报。有谁知道这是为什么吗? 最佳答案 functionisArray(o){return

javascript - 谷歌地图 API v3 - TypeError : Result of expression 'google.maps.LatLng' [undefined] is not a constructor

我正在创建一个静态html页面来显示数据中的多个位置。我刚刚复制了其中一个示例并正在向后工作,但我在Safari检查器中收到以下错误:main.js:1SyntaxError:Parseerrorsample.htm:10TypeError:Resultofexpression'google.maps.LatLng'[undefined]isnotaconstructor.这是我的html代码:MultiMarkersSampleviaGoogleMapsfunctioninitialize(){varmyLatlng=newgoogle.maps.LatLng(-30.2965590

javascript - 为什么 jslint 更喜欢 {}.constructor(obj) 而不是 Object(obj)

两者都将检测对象而不是基元。这似乎是纯粹的句法差异。//jslintprefers{}.constructor(obj)overObject(obj)//calledisObjectbyunderscore//willtestonlyforobjectsthathavewritablekeys//forexamplestringliteralswillnotbedetected//butarrayswillvarisWritable=function(obj){return{}.constructor(obj)===obj;}; 最佳答案