Question 9 of 10Pro Only

What is the difference between ES Modules (import/export) and CommonJS (require/module.exports)? When would you use each?

Sample answer preview

## Overview Two module systems in JavaScript: - **CommonJS (CJS)**: Node.js original system - **ES Modules (ESM)**: Modern JavaScript standard ## CommonJS (require/module.exports) ```javascript // math.js - Exporting module.exports = { add: (a, b) => a + b, subtract: (a, b) => a…

ES ModulesCommonJSimportexportrequiremodule.exports

Unlock the full answer

Get the complete model answer, key points, common pitfalls, and access to 9+ more Full-Stack Developer interview questions.

Upgrade to Pro

Starting at $19/month • Cancel anytime