ScanSkill

join

The join() method is used to join items present inside an array.

Syntax

array.join(joiningString)

The join() method attaches to the right side of an array with the . operator. It takes in a string as a parameter. The join() method returns a string that is the joined from of array, where each element is joined with the provided parameter.

Example

const fruits = ['apple', 'mango', 'banana'];

const joinedFruits = fruits.join('_');

console.log(joinedFruits); // Prints: apple_mango_banana

The join() method joins the array by the given join term, turning it into a string.