Skip to content

QuizNot attempted

Module scope

In an ES module (type="module"), what is top-level this?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • undefined
  • ES modules are always strict and their top-level code isn't called as a method of anything, so top-level this is undefined.
  • Not window: that is a classic (non-module) browser script.
  • Not module.exports: that is CommonJS top-level this.
  • Not the namespace object: you get it via import * as ns, never via this.