I have been racking my brain on this one for hours now and I have looked at probably 30 online tutorials by now. As far as I can tell, I am not doing anything wrong, but yet I am having problems. I have some test code:
TestPulse = function() {};
TestPulse.prototype.go = function() { alert('You just pulsed'); };
TestPulse.go();
I also tried:
function TestPulse() {};
TestPulse.prototype.go = function() { alert('You just pulsed'); };
TestPulse.go();
Finally fed up, I just ripped some code from a few prototyping and namespace tutorials around the web, and no matter what I do, I get the following error:
Uncaught TypeError: Object function TestPulse(){} has no method ‘go’
Like I said, I am not sure I am doing anything wrong…so what exactly is going on here? When I debug, I do see a prototype object attached to the function, with the constructor and all, so I know its there. Where is the issue? Am I not understanding how prototyping works?
You don’t have an instance of TestPulse…
http://jsfiddle.net/HYWPk/