Join array elements and separator - Javascript Array

Javascript examples for Array:join

Description

Join array elements and separator

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 ww . j ava2 s.  co m*/
    var values = [];
    values.push('agency_street');
    values.push(null);
    values.push('');
    values.push('agency_zip');
    console.log(values.filter(x => x).join(', '));
    }

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

Related Tutorials