搜索

首页  >  问答  >  正文

javascript - 新手求助:为什么这里的Console.log返回undefined?

function d(){this.get=function(){this.getNum()}};
d.prototype.getName=function(){return 3;};
var d = new d();
console.log(d.get());//undefined

为什么这里显示undefined?而不是3?求解答

滿天的星座滿天的星座2836 天前612

全部回复(6)我来回复

  • 怪我咯

    怪我咯2017-05-19 10:48:15

    雷雷

    回复
    0
  • 迷茫

    迷茫2017-05-19 10:48:15

    function d(){this.get=function(){return this.getNum()}};

    你说呢

    回复
    0
  • 某草草

    某草草2017-05-19 10:48:15

    function d(){this.get=function(){return this.getName();}};
    d.prototype.getName=function(){return 3;};
    var d = new d();
    console.log(d.get());

    自己对比下

    回复
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-19 10:48:15

    名字

    回复
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-19 10:48:15

    this.getnum改成this.getname

    回复
    0
  • 我想大声告诉你

    我想大声告诉你2017-05-19 10:48:15

    雷雷

    回复
    0
  • 取消回复