Subj : [Q] Parent objects, prototypes, inheritance and JS_InitClass... To : netscape.public.mozilla.jseng From : "t o b e" Date : Wed Nov 19 2003 08:36 pm Please help me with my understanding and correct me where I'm wrong: == Inheritance in Javascript is expressed through a chain of prototype objects. Each call to JS_InitClass takes an argument which is the prototype of the superclass and returns the prototype to the new class which is then passed to either JS_NewObject or JS_DefineObject to create an actual instance of the class. == Given this I've got the following questions: In JS_InitClass, what exactly is the second argument 'obj' used for. I seem to get decent results passing almost any JSObject in except NULL.. The API doc simply says 'Pointer to the object to use for initializing the class'. Eh ? Initializing in what way ? And why is it necessary to provide the property and function specs for the parent prototype in this situation ? Why do JS_DefineObject and JS_NewObject take arguments to both a JSClass and a prototype. ? Is the class argument completely redundant when an existing prototype is available ? Also.. what exactly is the 'parent' argument to these calls for. Can anyone define what 'parent' means in this context ?? I also don't have a clue what 'constructors' are for.. apart form initializing members, of course.. the docs suggest they allow you to specify static functions and properties for JSObjects but what this means precisely in a Javascript context I'm not sure... And lastly.. but by no means least.. are there any better guides/explanations to embedding Javascript than the rather cursory ones available on the mozilla website ? Any books you'd recommend ? Any help *very* gratefully received.. thanks in advance.. Toby Bradshaw Senior Engineer, Oregan Networks, London, UK. If you're replying directly please remove the NOSPAM in my e-mail address. .