Try to search your question here, if you can't find : Ask Any Question Now ?

Can somebody explain why i got a return of "undefined" while using "this" keyword

HomeCategory: stackoverflowCan somebody explain why i got a return of "undefined" while using "this" keyword
rupesh asked 1 week ago

I just started JS and only had this question based on the example below.

function Animal(name) {
    let animal = Object.create(Animal.prototype)
    this.name = name

    return animal
}

Animal.prototype.eat = function() {
    console.log(this.name +" is eating.")
}
let blackie = Animal("Blackie");
    blackie.name;
    blackie.eat();
1 Answers
Best Answer
Jyoti answered 1 week ago
Your Answer

19 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com