How you can include a JavaScript file to another JavaScript

Many programmers have queries that how they can include a JavaScript file to another JavaScript, Is there any way to achieve ? The answers is JavaScript does not support methods include, import, required like other programming languages supports. But there are some other ways available in JavaScript to import/include JavaScript file in another JavaScript file.

1. Loading JavaScript file using Ajax.

It is an easy way to add JavaScript file in another JavaScript file using Ajax call and then call eval method. eval() function evaluate or execute JavaScript code or expression. It is little risky if you are using eval() function in your code, it opens the door for bugs and hacks.

So here i discuss several ways load JavaScript file, you can adopt any one of these method and if you have another solution of the problem then comment below, I should consider and it also help for the readers.