June 7, 2023
Program to use JavaScript Array toString() method
let a = [1, 2, 'Apple', '3', '7', 'Banana'];
let b = a.toString();
console.log(b);
Output
1,2,Apple,3,7,Banana
Steps Description
- Declare two variable
a
andb
- Initialize two variable with value of array
a = [1, 2, 'Apple', '3', '7', 'Banana']
andb = a.toString()
- Array
toString()
method converts the array to a string. - The value of
b
variable is displayed with the help of console.log inbuilt function
by : Suhel Akhtar
Quick Summary:
JavaScript Array toString() method