What is the use of Namespace in Web Development ?

  • It refers to the programming paradigm of providing scope to the identifiers like name of types, functions, variables, etc. to prevent collisions between them.
  • The same variable name might be required in a program in different contexts for instance.
  • A group of related elements that each have a unique name or identifier is known as Namespace.
  • Namespaces are used in many areas of computing, such as, file paths,  domain names and XML
  • Using namespaces in such a scenario will isolate these contexts such that the same identifier can be used in different namespaces.
  • By default, JavaScript does not provide namespace.
  • It can contain all variables and functions however we replicate this functionality by making a global object.

Syntax:

  • Namespace to initialize an empty space.
[pastacode lang=”markup” manual=”var%20%3Cnamespace%3E%20%3D%20%7B%7D%3B” message=”” highlight=”” provider=”manual”/]
  • Namespace to access variable.
[pastacode lang=”markup” manual=”%3Cnamespace%3E.%3Cidentifier%3E” message=”” highlight=”” provider=”manual”/]

For example,

Output

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

What is the difference between SOAP and REST ?

                  SOAP                    REST It is a protocol. It is an architectural style. SOAP- Simple Object Access Protocol. REST- Representational State Transfer. It can’t use REST because it is a…
View Answer

What is Grid system ?

It is a structure comprising a series of vertical and horizontal lines which intersect and used to arrange content. Is a way of providing a system that designers can work with…
View Answer

What is Semantic HTML ?

It is essential to understand the meaning of words during communication in any language. It becomes more critical and provides more semantic elements which make it easy to understand the…
View Answer

What is Flexbox ?

It is a one-dimensional layout model that has efficient and flexible layouts with distributed spaces among items to control their alignment structure in CSS . It is a layout model…
View Answer