title: How and why does 'a'['toUpperCase']() in JavaScript work?
body: <p>JavaScript keeps surprising me and this is another instance. I just came across some code which I did not understood at first. So I debugged it and came to this finding:</p>
  
  <pre><code>alert('a'['toUpperCase']());  //alerts 'A'
  </code></pre>
  
  <p>Now this must be obvious if <code>toUpperCase()</code> is defined as a member of string type, but it did not make sense to me initially.</p>
  
  <p>Anyway,</p>
  
  <ul>
  <li>does this work because <code>toUpperCase</code> is a member of 'a'? Or there is something else going on behind the scenes?</li>
  <li><p>the <a href="http://danwebb.net/2006/11/3/from-the-archives-cleaner-callbacks-with-partial-application" rel="noreferrer">code</a> I was reading has a function as follows:</p>
  
  <pre><code>function callMethod(method) {
      return function (obj) {
          return obj[method](); //**how can I be sure method will always be a member of obj**
      }
  }
  
  var caps2 = map(['a', 'b', 'c'], callMethod('toUpperCase')); // ['A','B','C'] 
  // ignoring details of map() function which essentially calls methods on every 
  // element of the array and forms another array of result and returns it
  </code></pre>
  
  <p>It is kinda generic function to call <strong>ANY</strong> methods on <strong>ANY</strong> object. But does that mean the specified method will already be an implicit member of the specified object?</p></li>
  </ul>
  
  <p>I am sure that I am missing some serious understanding of basic concept of JavaScript functions. Please help me to understand this.</p>