In this article, you will learn about the javascript Array built-in method Array.prototype.join()
. How does this method work in javascript?
This Array.prototype.join()
method joins the elements of an array and returns a new string separated by commas or a specified separator string. If the length
of the array is 0
, then it will return the empty string.
Note: If the array has only one item, then it will return the string without using the separator.
If an element is undefined
, or null
in an array, it is converted to an empty string instead of the string "null
" or "undefined
"
This method takes 1 parameter as given below:
The join()
method does not change the original array.
Here are some examples of Array.prototype.join()
method:
I hope this article will help you to understand the javascript Array built-in method Array.prototype.join().
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!
Comments