title: How to assign value of array element by a arrow function
body: <p>I need to set one of the array property using arrow function. In my sample code I have added random key and an arrow function. but when I console the output, I cant see the &quot;random&quot; key. Can this be done using arrow functions.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let Allitems = {"items":[{"id":74489},{"id":64489},{"id":53489}]};
  
  const newarr = Allitems.items.map(e =&gt; ({...e, name:"newnamme", random: (e) =&gt; { return e.id + "random"; } }));
   console.log(newarr);</code></pre>
  </div>
  </div>
  </p>
  <pre><code>// expected output
  {&quot;items&quot;:[ 
  {&quot;id&quot;:74489,name:&quot;newnamme&quot;, random : &quot;74489random&quot;},
  {&quot;id&quot;:64489,name:&quot;newnamme&quot;, random : &quot;64489random&quot;},
  {&quot;id&quot;:53489,name:&quot;newnamme&quot;, random : &quot;53489random&quot;}]
  }
  </code></pre>