Javascript examples for Array:push
Create empty array and then push value
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* www. java 2 s . c o m*/ var namelist = []; function draw() { console.log(namelist.join(', ')); } function myFunction() { namelist.length = 0; // empty name list namelist.push('a'); namelist.push('b'); namelist.push('123'); draw(); } myFunction(); myFunction(); } </script> </head> <body> </body> </html>