RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
nodejs中的继承
  1. node(不推荐使用):
    a. 代码:
    var inherits = require("util").inherits; 
    function a(){
    this.name = "lee"
    }
    a.prototype.sex = "male"
    function b(){
    this.color = "red"
    }
    b.prototype.height = "168"
    function c(){
    }
    inherits(c,a)
    inherits(c,b)
    var c = new c()
    console.log(c.height)
    console.log(c.sex)
    console.log(c.name)

    b. 输出:

    专注于为中小企业提供网站设计、成都做网站服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业汾西免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

    168
    undefined
    undefined
  2. ecmascript(原生javascript):
    a. 代码:
    function a(){
    this.name = "lee"
    }
    a.prototype.sex = "male"
    function b(){
    this.color = "red"
    }
    b.prototype.height = "168"
    function c(){
    }
    c.prototype = new a()
    c.prototype = new b()
    var c = new c()
    console.log(c.height)
    console.log(c.sex)
    console.log(c.name)

    b. 输出:

    168
    undefined
    undefined
  3. 说明:
    1、只支持单继承
    2、不能作用于类本身的属性或方法(只支持prototype原型创建的属性或方法)
    不推荐使用

文章名称:nodejs中的继承
URL网址:http://scpingwu.com/article/gpcspg.html