JavaScript Code

JavaScript Array toString()

toString() – String Representation of Array

  • array is an array of elements
  • toString is the array method name

toString() method returns string representation of the given array. the string contains the elements of the array separated by comma


1. convert the array fruits to string, and print the string to console

let fruits = ['apple', 'banana', 'cherry', 'mango'];
let output = fruits.toString();

Copyright @2022