User:Jresig/JavaScript 2 Gotchas

<tt>override</tt> is required for overriding inherited properties

Consider the following (incorrect) example:

 class Artist {
   function draw(){}
 }
 
 class Designer extends Artist {
   function draw(){ /* ... new draw ... */ }
 }

The above will throw the following error (in the reference implementation):

 **ERROR** DefnError: illegal override of [ns public ]::draw  (near <no filename>:1:48-1.49)

You'll just to make sure that any functions or properties that you override from a base class that you properly mark with 'override', like so:

 class Artist {
   function draw(){}
 }
 
 class Designer extends Artist {
   override function draw(){ /* ... new draw ... */ }
 }

Document Tags and Contributors

 Contributors to this page: Jresig
 Last updated by: Jresig,