`
cy729215495
  • 浏览: 129195 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

use of prototype and call

 
阅读更多

 

functionStickman(){
//some methods and properties
}

functionJuniorStickman(){

Stickman.call(this);

this.p =new value // override a property in Stickman
}

JuniorStickman.prototype =new Stickman();

junior =new JuniorStickman();


call方法的作用,就像别的语言的super方法。但JuniorStickman.prototype =newStickman();是干嘛的,call方法已经让子类继承了父类所有的方法呀,还要他干嘛?
   原来它是继承父类的原型链的。但这种写法也不行。

如果Stickman有很多参数,那是不行的。
 JuniorStickman.prototype =Object.create(Stickman.prototype);就可以了

 

分享到:
评论

相关推荐

    Prototype Enumerable对象 学习第1/2页

    Enumerable provides a large set of useful methods for... Enumerable is what we like to call a module: a consistent set of methods intended not for independent use, but for mixin: incorporation into other

    GPU Instancer v1.5.4

    – Ability to use custom shadow distance per prototype and to choose the LOD to render shadows with. – Support for Floating Origin handling. – Multiple camera support. – Well documented API for ...

    acpi控制笔记本风扇转速

    code size, and reduces CPU stack use. (Valery Podrezov + interpreter changes in version 20051202 that eliminated namespace loading during the pass one parse.) Implemented _CID support for PCI Root ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Length Arrays and alloca() Friends Exceptions Run-Time Type Information (RTTI) Casting Streams Preincrement and Predecrement Use of const Integer Types 64-bit Portability Preprocessor Macros 0 and ...

    移动代理源代码

    Let's call JMF2.1.1 the installation directory of the JMF and JSDK the installation directory of the JSDK. Copy there files: ./JMF2.1.1/lib/jmf.jar ./JMF2.1.1/lib/sound.jar to the directory: ./...

    Sap Ruby Ajax

    This article delves into the details of integrating SAP and Ruby on Rails, focusing specifically on the use of AJAX within Ruby on Rails to enhance user experience. ## Installation Requirements To ...

    Turbo C 2.00[DISK]

    Computer brand, model, and the brands and model numbers of any additional hardware. d. Operating system and version number. (The version number can be determined by typing VER at the MSDOS prompt...

    Killtest提供 IBM 000-972 资料下载

    - **问题**:"Which of the following is an advantage gained by using a prototype and CALLP for a program call in place of CALL and PARM operations?" - **选项**: - A. Ability to qualify the name of ...

    simplewebrtc.js webrtc网页视频开发帮助工具

    var args = [].slice.call(arguments, 1), callbacks = this.callbacks[event], specialCallbacks = this.getWildcardCallbacks(event), i, len, item; if (callbacks) { for (i = 0, len = callbacks....

    CCS_C语言出错信息速查

    12. Call to function with no prototype - 调用了一个没有原型声明的函数,可能导致类型不匹配。 13. Cannot modify a const object - 不允许修改常量对象,尝试修改const变量。 14. Case outside of switch - 漏...

    常见C语言错误提示信息.doc

    11. **Call to function with no prototype**:调用了没有原型的函数,即函数声明缺失,可能导致类型不匹配。 12. **Cannot modify a const object**:尝试修改一个常量对象,常量对象的值在编译时就已经确定,不能...

    Replacing "RICHEDIT" control with "RichEdit20A"

    This is almost exactly what is in CRichEditCtrl::Create(), except the different window class name, and the call to AfxInitRichEdit() has been changed to AfxInitRichEditEx() which first calls ...

    hls.min.js

    return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/hls.js/dist/",e(e.s=7)}([function(t,e,r){"use strict";function i(){}function a(t,e){return e="["+t+"] >...

    C心得 编译时错误提示语句释义

    11. **Call to function with no prototype**:调用函数时,该函数未被预先声明,可能需要在调用前添加函数原型声明。 12. **Cannot modify a const object**:试图修改一个常量对象,常量在声明后不能改变其值。 ...

    C语言常见提示信息(很全面,很经典)

    11. **Call to function with no prototype**:调用函数时,如果没有函数原型,可能导致类型不匹配,需要提供函数原型。 12. **Cannot modify a const object**:尝试修改常量对象,常量在定义后不能改变。 13. **...

    程序设计编译常见错误提示

    11. **Call to function with no prototype**:调用了一个未定义函数原型的函数,需要在调用前先声明函数的返回类型和参数列表。 12. **Cannot modify a const object**:试图修改一个常量对象,常量在声明后不应...

    c语言出错信息汇总

    11. **Call to function with no prototype**:调用函数前没有原型声明,可能导致类型匹配错误。现代C编译器要求函数原型。 12. **Cannot modify a const object**:尝试修改常量对象,常量在声明后不应被修改。 ...

    VisualC++6.0编译连接出错汇总

    11. **Call to function with no prototype**:调用未声明的函数。在调用函数之前,确保已经提供了函数原型。 12. **Cannot modify a const object**:试图修改常量对象。常量对象在声明后不允许修改,如果需要修改...

    JavaScript中的this/call/apply/bind

    - 在严格模式(`use strict`)的函数中,`this`未定义。 - 在事件处理函数中,`this`指向触发事件的元素。 - 使用`call()`、`apply()`或`bind()`方法时,可以显式地指定`this`的值。 3. **绑定this的方法** - `...

Global site tag (gtag.js) - Google Analytics