search

Home  >  Q&A  >  body text

javascript - Does a self-executing function execute the function when it is loaded into this js?

(function() {
    'use strict';

    angular.module('app').controller('demoCtrl', demo);

    demo.$inject = [ '$location', 'demoSvc' ];

    function demo($location, demoSvc) {
        /* jshint validthis:true */
        var vm = this;
        vm.title = '';

        vm.showDialog = function() {

            $('.myDialog').modal({
                backdrop : 'static',
                keyboard : false
            });
        }

        function datetimePicker() {
            $("#datepicker").kendoDatePicker({
                culture : 'zh-CN'
            });
        }

        function upload() {
            $("#files").kendoUpload({
                async : {
                    saveUrl : "/demo/save",
                    removeUrl : "/demo/remove",
                    autoUpload : true
                }
            });
        }

        activate();
        function activate() {
            datetimePicker();
            upload();
        }
    }
})();

The code is as above. I would like to ask how it is loaded. Is the function inside already executed when it is loaded into this js?

習慣沉默習慣沉默2808 days ago712

reply all(2)I'll reply

  • 怪我咯

    怪我咯2017-05-16 13:21:41

    (function(){
        //
    })()

    is equivalent to

    var funcName = function(){
        ///
    }
    funcName();

    is equivalent to

    function funcName(){
        ///
    }
    funcName();

    Is that so?

    reply
    0
  • 为情所困

    为情所困2017-05-16 13:21:41

    (function(){
        console.log(123)
    })()
    

    Self-executing function

    reply
    0
  • Cancelreply