Christoph M. Becker
4/9/2015 2:32:00 PM
Thomas 'PointedEars' Lahn wrote:
> Christoph M. Becker wrote:
>
>> Denis McMahon wrote:
>>> I haven't tested the following code, but it might return a result object
>>> that either contains the results you want, garbage, or a single error
>>> attribute.
>>
>> <snip>
>>
>>> Sorry it's not a class object, but I've never really grokked the whole
>>> emulate OOP with javascript using functions as classes thing[1].
>>
>> It appears that the function can be used as constructor function
>
> No, it cannot. It is syntactically invalid to begin with.
Indeed. I had to replace instanceOf with instanceof (and a string
literal that was split due to Usenet posting) to be able to run the
function. I did not go further.
>> and called with `new election([...])`, so all is well. ;)
>
> It is a fundamental misconception that OOP requires classes. You do _not_
> emulate OOP using functions as constructors in most ECMAScript
> implementations; you *do* OOP, just a special kind of prototype-based OOP.
ACK. However, neither the OP nor Denis seem to be really insterested in
such (and other) "subtleties", which caused me to post my reply which
was meant ironically.
Thanks, however, for clarifying the issue for other readers. :)
--
Christoph M. Becker