Google News
logo
Underscore.js - Interview Questions
Passing an array of numbers to the _.max function() in Underscore.js.
The ._max() function takes the element from the list one by one and do compares the elements to find the maximum number in the list. After traversing and comparing all the elements, the _.max() function ends.
 
Example :
<html>
    <head>
        <script type="text/javascript" src = 
"https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js" >
        </script>
    </head>
    <body>
        <script type="text/javascript">
            var numbers = [100, 50, 400, 66, 999];
            console.log(_.max(numbers));
        </script>
    </body>
</html>

Output : 
Max Function

Advertisement