Hello!
Just made the switch from C#/C++ to JavaScript recently and I'm really enjoying it.
I've encountered a behavior that has me scratching my head, can anyone help explain?
So here's what's happening: when I run this script, I see the expected alert displaying '5.5', but then after closing that alert, another one pops up showing only "undefined". Any ideas why this is happening?
Code snippet:
var myObj = {
age : 5,
weight : 5.5,
toString : function(){
alert(this.weight);
}
}
alert(myObj.toString());
Appreciate any insights you could offer.