Javascript examples for Array Operation:Array Element
Use object literal as array element
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from ww w . j a va2 s. c om*/ var site = { name: 'stackoverflow' }; var users = [ { name: 'hi'} ]; for (var i = 0; i < users.length; i++) { users[i].site = site; } site.users = users; console.log(site.users); } </script> </head> <body> </body> </html>