Javascript - What is the output: export statement is part of an if statement?

Question

What is the output of the following code?

if (condition) { 
    export condition; 
    
} 


Click to view the answer

// SyntaxError: 'import' and 'export' may only appear at the top level

Note

Both export and import need to be used only at the top level and cannot be part of other statements or functions.

Here, the export statement is part of an if statement, which throws an error.

Exports and imports cannot be executed conditionally or dynamically in any way.

Related Quiz