Using third-party libraries in JavaScript involves adding a reference to the library in your project and then using the various functions or features provided by it. Here’s how you can do this:
Firstly, you need to install the library. This can be done in two ways:
1. Via A Content Delivery Network (CDN)
A CDN is a system of distributed servers that deliver pages and other web content to a user, based on the geographic locations of the user.
Use the following script tags to include Lodash & Moment.js libraries in HTML file.
For Lodash:
```
```
For Moment.js:
```
```
1. Via NPM (Node Package Manager)
If you’re using Node.js, you can make use of npm to install these libraries.
For Lodash:
```
npm install lodash
```
For Moment.js:
```
npm install moment
```
After installing the library, you’re free to begin using it in your JavaScript code.
For Lodash, you need to import it like this:
```
var _ = require(‘lodash’);
```
You can, then, use its functions like this:
```
_.isNumber(3);
_.isString(‘hello’);
```
For Moment.js, import it like this:
```
var moment = require(‘moment’);
```
And use it like this:
```
console.log(moment().format(‘MMMM Do YYYY, h:mm:ss a’));
```
Note: To use npm and require, you must have Node.js and npm installed and your project should be set up to use Node.js. If you’re running your code directly in a browser (instead of a Node.js environment), then adding the script tag for the library in your HTML file is the correct approach.