How do I create an object with methods

How do I create an object with methods

This may be more of a JavaScript question than a jQuery question, unless there is a better jQuery way to do it.

I want to create an object that has methods.

So I looked up how to do this on the internet, and got the following snippet:

  1.  textplayer = new Object();

    function textplayer() {

        function getDuration() {

        var retval;

        retval = 55;

        return (retval);

       }

    this.getDuration = getDuration;

    }

then I should be able to call textplayer.getDuration(); It does not work, and neither to alternate methods such as: this.getDuration = function() { ...}

Any help is appreciated.







It does not work.  I tried alternate methods, such as: this.getDuration = function () { .... } but that did not work either.

  1. What is the right method of doing this?