Introduction to using JavaScript namespaces _ javascript skills

Source: Internet
Author: User
It is not so comfortable to use JavaScript to implement namespaces. Javascript only has function scopes, and all parts of it are considered as a namespace, sometimes errors caused by duplicate names are confusing, and it is difficult to debug and solve problems that students who have used Java and C # are very familiar with namespaces, in a complex system, there will be N more functions, objects, languages, pre-defined architectures, and so many functions and objects. Due to the requirements of programming specifications, there are actually meaningful names, it is inevitable that duplicate names will be called incorrectly, but with namespace troubles, they will not only be able to classify organizational functions and objects, but also form isolation to solve the problem of duplicate names.

JavaScript is not so comfortable. Javascript only has a function scope. What block of files are considered as a namespace? Sometimes, errors caused by duplicate names are puzzling, difficult to debug.

A simple example

The Code is as follows:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.