f29lba
Last Updated: March 02, 2016
·
146
· szymonkor
Zrzut ekranu z 2016 04 16 07 43 55

calculate min and max element of an array in JavaScript

Math.min.apply(Math, [1,2,3,4,5,6]);
Math.max.apply(Math, [1,2,3,4,5,6]);

Knowing the difference between apply and call is essential for any JS developer. I strongly recommend reading this article: http://javascriptissexy.com/javascript-apply-call-and-bind-methods-are-essential-for-javascript-professionals/

SOURCE: http://slopjong.de/2014/02/12/calculating-the-minmax-value-from-an-array-in-javascript/

Say Thanks
Respond