Finding a "safety syntax" for classes

Rick Waldron waldron.rick at gmail.com
Tue Mar 20 11:09:14 PDT 2012


[ ... snip ]

> class Animal {
>>
>>     constructor(name){
>>
>>         this.name = name;
>>
>>     }
>>
>>     move(meters){
>>
>>         alert(this.name + " moved " + meters + "m.");
>>
>>     }
>>
>> }
>>
>
Russ,

I'm trying to write up some supporting examples, but ran into a snag
regarding "static" properties. eg

function Foo( stuff ) {
  this.stuff = stuff || "";
}

Foo.prototype.getStuff = function() {
  return this.stuff;
};

Foo.Bar = function() {
  return new Foo("bar");
};


How would I make Foo.Bar ?


Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120320/407738e8/attachment-0001.html>


More information about the es-discuss mailing list