I began studying JavaScript yesterday, today I was at the object and functions topic.
I'd already made this work, but I'm really in doubt why in the dog1 object, if I use the this keyword I just get "undefined" return on the log.
I'd already search this here and on google, but without luck. I'm not looking for a code to solve this, just to understand why in the second case the "this" is not working.
var dog0 = {
Name: "Bob",
color: "Golden",
breed: "Labrador",
dogcard1: function() {
return "Hi, this is " + this.Name + ", a " + this.color + " " + this.breed ;
}
};
console.log(dog0.dogcard1());
function dogcard(a, b, c) {
return "Hi, this is " + a + ", a " + b + " " + c ;
}
var dog1 = new Object();
dog1.Name = "Suzy";
dog1.color = "black";
dog1.breed = "Bulldog";
dog1.presentation = dogcard(this.Name, dog1.color, dog1.breed);
console.log(dog1.presentation);