javascript - Newbie asking for help: Why does Console.log here return undefined?
滿天的星座
滿天的星座 2017-05-19 10:46:15
0
6
605

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

Why is undefined shown here? Instead of 3? Please answer

滿天的星座
滿天的星座

reply all(6)
刘奇
function d(){this.get=function(){return this.getName()}};
d.prototype.getName=function(){return 3;};
var d = new d();
console.log(d.get());//undefined
迷茫
function d(){this.get=function(){return this.getNum()}};

What do you say

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

Compare for yourself

过去多啦不再A梦

num name

曾经蜡笔没有小新

this.getnum is changed to this.getname

我想大声告诉你
function d(){
            this.get= function(){
                return this.getName()
            }
        };
        d.prototype.getName = function(){
            return 3;
        };
        var d = new d();
        console.log(d.get());  
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template