Math.min() Math.max() …rest

Actionscript:
  1. trace("min", Math.min(100, 99, 32, 75, 44, 90));
  2. trace("max", Math.max(100, 99, 32, 75, 44, 90));
  3. /*outputs:
  4. 32
  5. 100
  6. */

It's easy not to notice that Math.min() and Math.max() can take any number of arguments. I've seen people nest min/max calls instead of using the above option.... like this:

Actionscript:
  1. trace(Math.min(1, Math.min(2, 3)));

This entry was posted in misc and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*