title: javascript : dictionary of functions with "constant" integer as keys
body: <p>The following code is working fine:</p>
  
  <pre><code>function a() { console.log("a"); };
  function b() { console.log("b"); };
  
  var F = {1:a,2:b};
  
  F[1](); // log "a"
  F[2](); // log "b"
  </code></pre>
  
  <p>but this one does not:</p>
  
  <pre><code>function a() { console.log("a"); };
  function b() { console.log("b"); };
  
  var A = 1;
  var B = 2;
  var F = {A:a,B:b};
  
  F[A](); // log "TypeError : F[A] is not a function"
  </code></pre>
  
  <p>The idea is that A and B would be constant integer, used just for the sake of code readability. I know there are no "const" in javascript, but you get the idea.</p>
  
  <p>What would be the clean way to get something like this work ? (I do not care that much if A and B are effectively constant or not at the end, just having them upper case indicates my future me not to change their value).</p>