Every object has its own scope. A scope is a block of code where the object is accessible. Namespace defines the scope of their objects. The type of scope exist:

  • Local scope: The object is accessible only inside the block such as the function where it is defined. 
  • Global scope: The object is defined outside all the functions and modules. So, it can be accessed anywhere in the program. 
  • Module-level scope: The object is accessible in the complete module as a global object where the program is written.