Javascript default behavior of load method

2014/8/21 min read
bookmark this
Responsive image

Was curious and although I think I kind of know the result but just want to do a check what's default javascript behavior to load the method.
Should I always put the method to the beginning of the script or end of the script.

Looks like I can't put the end of the script, javascript will return error says, function is not defined.


script
        var beginningOfInlineJs = function () {
            console.info("beginningOfInlineJs");
        };


        (function () {
            var myVariable = "my_private_stuff";
            var privateMethod = function () {
                console.info("hi");
            }

            var privateMethod2 = function (msg) {
                console.info(msg);
                return myVariable + msg;
            };

            var init = function(){
                privateMethod();
                beginningOfInlineJs();
                endOfInlineJs();                
            };

            init();
            return {
                public1: privateMethod,
                public2: privateMethod2
                
            };

            
        })();

        var endOfInlineJs = function () {
            console.info("endOfInlineJs");
        };
    
///script