Javascript default behavior of load method

2014/8/21 min read
bookmark this

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.

        var beginningOfInlineJs = function () {

        (function () {
            var myVariable = "my_private_stuff";
            var privateMethod = function () {

            var privateMethod2 = function (msg) {
                return myVariable + msg;

            var init = function(){

            return {
                public1: privateMethod,
                public2: privateMethod2


        var endOfInlineJs = function () {