title: Javascript: How to get the parent key inside a function?
body: <p>I've some functions, stored in a collection/array and would like to get the key (function-name) without retyping it. Is there any short way to access it? </p>
  
  <pre><code>var functions_collection = {
      "function_x": function() {
          var name = "function_x";
          // name = this.key; &lt;- how to get the key/function-name "function_x"?
  
          // some more code like:
          $(".function_x .button").val();
  
          alert(name);
      }
  }
  </code></pre>
  
  <p>Edit: I'd like to avoid retyping the "function_x" inside the function itself and prefer to call it like this.key.</p>
  
  <p>Sorry for the weird topic and thanks in advance!</p>
  
  <p><strong>Solution</strong>: A lot of good answers, but I was just looking for this snipped:</p>
  
  <pre><code>Object.keys(this)
  </code></pre>