Variable in a Closure
<p>I have a JS object, in a property I use a function expression, within a variable result.</p>

<p>I need to populate the result variable and return it when processData has been invoketed.</p>

<p>Could you tell me what I'm doing wrong here, if you brief explain the problem and add a pieec of good would be great.</p>

<pre><code>$(document).ready(function () {

    // General Settings
    var 
    ApiSettings = {
        clientId: 'aaa',
        clientSecret: 'bbb'
    }

    ApiSettings.uriGetToken = 'https://ccc.com/oauth/token?grant_type=client_credentials&amp;client_id=' + encodeURIComponent(ApiSettings.clientId) + '&amp;client_secret=' + encodeURIComponent(ApiSettings.clientSecret);

    ApiSettings.token = (function () {
        var result; // I'm not able to set this variable
        // Make an Ajax Request
        $.getJSON(ApiSettings.uriGetToken, processData);
        function processData(data) {
            result = data.access_token;
        }
        return result;
    })();

    console.log(ApiSettings);
    console.log(ApiSettings.uriGetToken);
    console.log('FINAL:' + ApiSettings.token);
});
</code></pre>
