I’m having an issue with Javascript object literals.
I would like to reference the object within one of the functions:
var Obj = {
name : "Johnny",
dumb : function() {
alert(this.name);
}
}
Sadly, the “dumb” function is an object as well. So, since dumb() has no
‘name’ property, it will return as undefined.
How do I get around this?
dumbis a method on your Obj object. When called,thiswill be set toObj, and will alert “Johnny”Try it out