简体   繁体   中英

Nested Objects in Bootstrap.js

I'm making some improvements to a Combobox class I made to go with Bootstrap 4, and I wanted to make the Javascript match what already exists in Bootstrap.

In the process, I found some code that I don't quite understand in bootstrap.js while checking out the Modal:

var Modal = function () {
    var NAME = 'modal';
    // Other Constants

    var Modal =
    /*#__PURE__*/
    function() {
        function Modal(element, config) {
            this._config = this._getconfig(config);
            // Other Assignments
        }

        var _proto = Modal.prototype;
        // Other Prototype Assignments
    }();
}($);

My question is this: Why is var Modal = function() ... nested inside itself? What does this nested pattern accomplish? Should I use this pattern in my Combobox?

我们使用Babel在ES5中编译我们的插件,但是我们的代码源在ES6中,所以对我来说,这个问题应该与Babel问题相关

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM