Creating a javascript object Using object initializers
<p>I'm kind a new in Javascript and I have this situation:
I have a separated javascript file and I created a javascript object in this way:</p>

<pre><code>$(document).ready(function () {    
    var formasPagamento = {
        Cartao: 0,
        Crediario: 1,
        Vale: 2
    };
});
</code></pre>

<p>In this same file, I have a function and I want to use this object formasPagamento, but when I try to use it, I get the error that formasPagamento is undefined.</p>

<p>Ex:</p>

<pre><code>function CarregarDetalhesPlanoPagamento(idPosDocPagamento) {    
     if(idPosDocPagamento == formasPagamento.Cartao){ //undefined here
         //do something
     }
}
</code></pre>

<p>What's the proper way to initializa a "global" variable that can be used in another function?</p>