An "extend" operator is a natural companion to <|

Rick Waldron waldron.rick at gmail.com
Mon Jul 18 21:02:45 PDT 2011


Hey Bob, FWIW...


> class Point {
>   constructor(x, y) {
>     this.x = x;
>     this.y = y;
>   }
>
>   zero() {
>     return new Point(0, 0);
>   }
>
>   unit() {
>     return new Point(1, 1);
>   }
>
>   prototype {
>     manhattanDistance() {
>       return Math.abs(this.x) + Math.abs(this.y);
>     }
>   }
> }
>

...That's actually the nicest, most intuitively designed "class" structure
I've seen so far.

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110719/233156d6/attachment.html>


More information about the es-discuss mailing list