Your code is ok. The dumb call should be:
Obj.dumb(); // "Johnny"
this in JavaScript is completely determined by how the function is called, not where the function is defined. If you call a function through an object property, inside the call this will refer to the object. For example, if you did this:
var f = Obj.dumb; f();
... then you will get undefined (well, probably), because you have not set any specific value for this . In the absence of a specific value, a global object is used. ( window , in browsers.)
You can also set this using call functions or apply JavaScript functions:
var f = Obj.dumb; f.call(Obj);
The first argument to call (and apply ) is the object to use as this . (With call any subsequent arguments are passed to the function, so f.call(Obj, 1); will be effective. In apply second argument is an array that will be used as arguments for the function, so f.apply(Obj, [1]); will be effective Obj.dumb(1); )
Additional Information:
source share