Google News
logo
Underscore.js - Interview Questions
How to Installation Underscore.js?
We can use Underscore.js directly inside the browser and also with node.js. We will discuss both of these methods.
 
Method 1 : Use directly inside the browser. 
 
Visit the official website (https://underscorejs.org/) and download the latest underscore-min.js file UMD available. After that include the following CDN link inside your code in order to run the underscore.js code inside the browser.
Method 2 : We can install it with npm. Make sure that you have Node.js and npm installed.
npm install underscore
You can also install with yarn
yarn install underscore
<!DOCTYPE html>
<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 : 
Install

Advertisement