Home > Web Front-end > JS Tutorial > Another implementation of JS namespace_javascript skills

Another implementation of JS namespace_javascript skills

WBOY
Release: 2016-05-16 17:25:55
Original
1137 people have browsed it

Copy code The code is as follows:

//, create a default, global namespace
var Company = {};
//Use objects to create sub-namespaces
Company.project = {};
//Create the final namespace, including some attributes whose values ​​are functions
Company.project.OA = {
add: function(a, b) { return a b; },
subtract: function(a, b) { return a - b; }
};

//Call
Company.project.OA.add(num1, num2);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template