Convert array to string and change each element - Javascript Array Operation

Javascript examples for Array Operation:Array Convert

Description

Convert array to string and change each element

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(){/*  ww w. ja  va2  s . c om*/

var array = ['1', '2', '3'];
var ret = "";
for (var i = 0; i < array.length; i++) {
  ret += "\"" + array[i] + "\",";
}
ret = ret.substr(0, ret.length - 1); // remove last ,
console.log(ret);

    }

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

Related Tutorials