title: Anonymous functions inside an object
body: <p>I have a Javascript snippet like this:</p>
  
  <pre><code>var a = {ac: 10, function(){console.log("hi")}}
  </code></pre>
  
  <p>The browser is not throwing an error for this. So it may be valid.   </p>
  
  <p>But when I use </p>
  
  <pre><code>var a = {ac: 10, function hi(){console.log("hi")}}
  </code></pre>
  
  <p>The browser throws error: </p>
  
  <blockquote>
    <p>Uncaught SyntaxError: Unexpected identifier</p>
  </blockquote>
  
  <p>Can anybody tell me how can I make use of the first code in any scenario in Javascript</p>
  
  <p>Thanks in Advance</p>