>> guess) it a pain.  the javascript class code structure it also very
>akword
>> to be coming from a C++ background.
>
>Amen, and i had the same hurdle to climb, but JavaScript isn't C++. It
>uses a completely different type of OOP. These articles may be helpful
>in understanding it:
>
>Implementing classical inheritance in JS:
>http://javascript.crockford.com/inheritance.html
>
>Understanding Prototypal inheritance:
>http://javascript.crockford.com/prototypal.html
>
>It's interesting to note that while the first article is quite famous,
>and does show how to implement C++-like inheritance in JS, the author
>of the article no longer stands by that method, preferring prototypal
>inheritance instead.

This is just my opinion, but one reason I prefer to create JS objects the
way ECMA has defined the syntax is it helps me to keep in mind that
JavaScript is not C, Java, C++ or C#--it's JavaScript.

If you end up trying to copy coding techniques from another language too
closely, I find myself expecting that language to behave accordingly. That
usually gets me into trouble. 

So while it coding your JS objects in a way that fits your C++ familiarity
may help you develop code a little faster out of the box, it's important to
realize that JS is not C++ and it has its own caveats and quirks. 

I'm sure you realize this, but sticking with the native JS object creation
methods has helped to limit confusion for me...

-Dan

Reply via email to