C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Array join() methodThe JavaScript array join() method combines all the elements of an array into a string and return a new string. We can use any type of separators to separate given array elements. SyntaxThe join() method is represented by the following syntax: array.join(separator) ParameterSeparator() - It is optional. It represent the separator used between array elements. ReturnA new string contains the array values with specified separator. JavaScript Array join() method exampleLet's see some examples of join() method. Example 1Let's see a simple example of join() method. <script> var arr=["AngularJs","Node.js","JQuery"] var result=arr.join() document.write(result); </script> Output: AngularJs,Node.js,JQuery Example 2In this example, we will separate the array elements using '-' separator. <script> var arr=["AngularJs","Node.js","JQuery"] var result=arr.join('-') document.write(result); </script> Output: AngularJs-Node.js-JQuery
Next TopicJavaScript Array
|