MCQ Single Best Answer Easy

QWhat steps may be taken to prevent JavaScript from creating global variables?

ID: #5022 Javascript Modules MCQ 369 views
Question Info
#5022Q ID
EasyDifficulty
Javascript Modules MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A To use a method that defines all the variables
  • B To use an object that has the reference to all the variables
  • C To use an object as its namespace
  • D To use global functions
Correct Answer: Option C

Explanation

To prevent the creation of global variables, a module can use an object as a namespace.
This means that instead of defining global functions and variables, the module stores them as properties of an object, which may be linked to a global variable

Share This Question

Challenge a friend or share with your study group.