Javascript Data Type How to - Convert array to string with separator








Question

We would like to know how to convert array to string with separator.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
<!--from  www .j  ava  2  s.c om-->
    var arr = [12,13,14];
    arr = arr.join("|");
    document.writeln(arr);
    document.writeln(typeof arr);

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

The code above is rendered as follows: