Expand Messages
• You may also write the code this way var Which = Math.round(Math.random()) ? One : Two; var x = new Which( 1 , 2 , 3 ); ;-)
Message 1 of 6 , Mar 9, 2011
You may also write the code this way

var Which = Math.round(Math.random()) ? One : Two;
var x = new Which("1", "2", "3");

;-)
• ... That takes care of the error, thank you! :-) [Non-text portions of this message have been removed]
Message 2 of 6 , Mar 9, 2011
On Wed, Mar 9, 2011 at 9:58 AM, Alexandre Morgaut <morgaut@...>wrote:

>
>
> You may also write the code this way
>
> var Which = Math.round(Math.random()) ? One : Two;
> var x = new Which("1", "2", "3");
>
>
That takes care of the error, thank you! :-)

[Non-text portions of this message have been removed]
• Your code is a perfect example of clever -- one of the best tools a coder has for showing their ingenuity and skill while simultaneously confusing people
Message 3 of 6 , Mar 9, 2011
Your code is a perfect example of "clever" -- one of the best tools a coder
has for showing their ingenuity and skill while simultaneously confusing
people reading the code later. I grant that it is more lengthily to make
your intentions clear, but to do so would almost certainly lead to a faster
understanding for you and others in a month when you're debugging it. Use
this rule of thumb consistently and it'll lead to higher productivity and
lower maintenance costs for all involved.

Rob

-----Original Message-----
From: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] On
Behalf Of Stjepan Rajko
Sent: Wednesday, March 09, 2011 8:13 AM
To: jslint_com@yahoogroups.com

Hello,

On the following code:

function One(a, b, c) {
````this.value = a + b + c;
}
function Two(a, b, c) {
````this.value = c + b + a;
}
var which = Math.round(Math.random());
var x = new (which ? One : Two) ("1", "2", "3");

JSLint gives:

*Error:*

Problem at line 8 character 31: Bad constructor.

var x = new (which ? One : Two) ("1", "2", "3");
**
After a brief look at the ECMAscript spec I think this is valid code but I'm
not 100% sure. In any case, I was wondering if anyone could help me