views:

86

answers:

5

Hi,

I'm trying to write a software in JavaScript, but I'm having hard time trying to get the idea of all this prototype and other wicked looking inheritance stuff.

What I would like to know are the different ways to get inheritance, and the pros and cons of each.

+1  A: 

Have a look at this tutorial.

tangens
John's forthcoming book "Secrets of the JavaScript Ninja" is also good, but mirrors much of what Crockford does in "Good Parts".
bdl
+3  A: 

Also good: http://javascript.crockford.com/

and http://mckoss.com/jscript/object.htm too

Pointy
+3  A: 

If you're writing Javascript, I highly recommend reading or watching Douglas Crockford. In particular, he has a talk called Javascript: The Good Parts.

Michael Williamson
+2  A: 

"JavaScript: The Good Stuff" if you like books.

duffymo
+2  A: 

You can try to use javascript not like a pure object oriented language(which isn't) but something that use functions and closures which are its specificity.

function _class(init){
    var _private = init;
    return {
        _method:function(param){
            alert(_private + param);
        }
    };
};
_class('Stack')._method('Overflow');

If you have the courage to read/debug it, the source code of jQuery is a very good example of javascript usage.

Mic