lcgyh / myDocs

0 stars 0 forks source link

面试题-代码输出 #53

Open lcgyh opened 5 years ago

lcgyh commented 5 years ago
function Person(){
    getAge=function(){
        console.log('5');
    }
    return this
}

Person.getAge=function(){
    console.log(4)
}
Person.prototype.getAge=function(){
    console.log('3')
}

var getAge=function(){
    console.log('2')
}

function getAge(){
    console.log(1)
}

getAge();
Person.getAge();
Person().getAge();
getAge();
new Person.getAge();
new Person().getAge();
lcgyh commented 5 years ago

2,4,5,5,4,3