what is the difference between require() and include() when an error is encountered?



what is the difference between require() and include() when an error is encountered?..

Answer / Simpal Chauhan

In JavaScript, there are no built-in functions called 'require()' or 'include()'. However, in CommonJS (used by Node.js) there is a function called 'require()'. When an error is encountered while loading a module with require(), it throws an exception that can be caught and handled using try-catch blocks. On the other hand, when using 'include()' or 'script' tags in HTML, if an error occurs during loading, the script execution will stop, but no exception is thrown.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Web Related AllOther Interview Questions

what is web methods?

1 Answers  


What are the available environments on the web?

1 Answers  


Difference between display none and visibility hidden ?

1 Answers  


How do I provide information to the Web Service when the information is required as a SOAP Header?

1 Answers  


Enlist some important test scenarios for testing a website.

1 Answers  


What's the difference between *.vsdisco and *.disco file?

1 Answers  


what is the difference between require() and include() when an error is encountered?

1 Answers  


What software do you use to build websites? Give me an example of a project that you built using JavaScript. What kind of functionality did you create?

1 Answers  


Can you get a virus from website?

1 Answers  


What are namespaces? Why are they important?

1 Answers  


How to troubleshoot if you get the error as application pool is hanges?Answer me in step by step procedure?

1 Answers   IBM,


What are the common problems faced in web testing?

1 Answers  


Categories