I have a JavaScript object with a privileged method. When this method has completed, I would like it to call itself (after a small timeout) and continue running indefinitely
Because this outside the function is not the same as this inside the function. Try instead:
function Test() {
// ... private variables that testMethod needs to access ...
var me = this;
this.testMethod = function() {
alert("Hello, from the method.");
setTimeout(me.testMethod, 2000);
};
}