Question: Can some one explain what is the difference between these two code blocks? Why would we ever need the first type when second one is more concise.

First

```
var Utility;
(function (Utility) {
    var Func = (function () {
        function Func(param1, param2) {
            var self = this;
            this.Owner = param2;
        }
        return Func;
    })();
    Utility.Func = Func;
})(Utility || (Utility = {}));

```

Second:

```
var Utility;
(function (Utility) {
    Utility.Func = function (param1, param2) {
            var self = this;
            this.Owner = param2;
        }
})(Utility || (Utility = {}));

```

context: First version was code generated by typescript compiler and I am trying to understand why did it generate the first instead of a simpler second.

Answer: 
The only difference between the code blocks is that the first has a function scope around the code that creates the `Func` function. The only reason to do that would be to create a scope where you can declare variables that would not be available in the outer scope:

```
var Utility;
(function (Utility) {
    var Func = (function () {

        var x; // a variable in the inner scope

        function Func(param1, param2) {
            var self = this;
            this.Owner = param2;
        }
        return Func;
    })();

    // the variable x is not reachable from code here

    Utility.Func = Func;
})(Utility || (Utility = {}));

```
from what I see they are the same, in both cases you are defining the function and making it as a member of Utility, the calling it.
Add to it, no scope differences, no context differences, no difference really.
I think it's a matter of preference nothing more.

But, I can see one potential difference, in case the very inside one was a `async` function call, there might be a difference , since `Utility.Func` will end up having `undefined` as a value, which is a very big problem with the first one, but I doubt the person writing it will not notice.