JavaScript Program to Demonstrate Use of concat() and join() methods of array

Write a JavaScript program to demonstrate use of concat() and join() methods of array.



Source Code
<html>
<head>
    <title>Demonstrate concat() and join() methods of array</title>
</head>
<body>
<script>
    var fruits = ['Apple', 'Orange', 'Banana'];
    var s1 = fruits.concat();
    var s2 = fruits.join('->');

    document.write("Using concat() : " + s1); 
    document.write("<br>Using join() : " + s2); 
</script>
</body>
</html>
Output





"Coding Hub - Learn to code" app now available on Google Play Store