Confused about this javascript pattern

javascript

Solution

this pattern is an "Immediately Invoked Function Expresssion". in short, it's just a function that is executed immediately. the `this` on the end is a parameter to be sent to the inner function that will be accessed as `exports`

(function(exports){

    //that was "this" outside, is now "exports" in here

}(this));

in your example, we can assume that whatever `this` was, it's some object that has been added a `Move` method to it.

some also call this pattern the "Module Pattern" in a sense that it creates a "contained environment" so that the stuff inside it is not visible to the due to a new function scope. in other words, whatever is inside sees the outside, but the outside can only see what the inside lets it see

Problem

Encounter following lines of code, but couldn't understand it. What is this (/.../)(this); purpose in javascript? Does it have name for this pattern? Code as below: ``` //Move.js (function(exports){ exports.Move = function(){ }; })(this); ```

Original source