(Sorry I didn't reply right away, I am in Austin at TXJS)
I agree about the ternary operator but that won't work if "something else" has
more than one statement. And your example is awesome, thanks!
Anton
On Wednesday, June 8, 2011 at 5:49 PM, Angus Croll wrote:
> It might be clearer to do this:
>
> function sample(callback) {
> // Do something
> cond ? callback() : // Do something else
> }
>
>
> Here's a function that sums values of an array then multiples total by x.
> void ensures the final multiply exits the loop
>
> for (var i=arr.length, r=0; i-- || void (r = r*x); r += arr[i]);
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]
> (mailto:[email protected])
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]