Push value to same array key - Javascript Array

Javascript examples for Array:push

Description

Push value to same array key

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   w w w .  j a  v a 2s  .  c o  m*/
var obj = {0:{name:'amy', age:10}, 1:{name:'bob', age:10}, 2:{name:'Tom', age:11}};
obj.age = Object.keys(obj).map(function (el) {
  return obj[el].age;
});
console.log(obj.age);
    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials