Why does in the following code, i don't see output as T12345 ABC
and instead i see undefined undefined.
The reason i am expecting T12345 ABC
because myCarDetails now refer to global context and global context have registrationNumber and brand defined
.
var registrationNumber = "T12345";
var brand = "ABC";
var car = {
registrationNumber: "T12345",
brand: "ABC",
displayDetails: function(){
console.log(this.registrationNumber + " " + this.brand);
}
}
var myCarDetails = car.displayDetails;
myCarDetails();