Displaying elements of an array by using join() methodYou have seen displaying elements of an array by looping through the array. Now we will see how to display elements of an array by using join method. Join() method is a built in method in JavaScript which takes a delimiter and create a string by adding all elements of the array by placing the delimiter between them.This is another way to display all elements and if we give line break <br> as delimiter then all elements we can display vertically in any web page. We need not loop through by using length property. We can directly display elements by using document.write or we can assign it to one string variable and then display.
Here is the complete code for displaying elements of an array using join
The output of the above code is here
You can use line break <br> to generate a list by using the last line of the above code.
This article is written by plus2net.com team.
![]() | ||||
![]()
| ||||