Help with prototype object

Posted by nemiss on Stack Overflow See other posts from Stack Overflow or by nemiss
Published on 2010-04-03T12:48:31Z Indexed on 2010/04/03 12:53 UTC
Read the original article Hit count: 254

Filed under:
|

Hi, I am mlearning javascript and have some trouble creating an onject via prototype.
I have this:

 <script type="text/javascript">

        function myclass(a, b, c) {
            if (arguments.length) { this.Init(a, b, c); }
        }
        myclass.prototype.Init = function(a, b, c) {
            this.param1 = a;
            this.param2 = b;
            this.param3 = c;
        };
        myclass.prototype.Print = function() {

            alert(this.param1 + '-' + this.param2 + '-' + this.param3);
        };

        var myObject = myclass(3, 5, 6);
        myObject.Print();


    </script>

but I get an error on line with this.Init(a, b, c);
Error: Object doesn't support this property or method

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about prototype