I have an array
let arr = [12,12,43,53,56,7,854,3,64,35,24,67]
i want the result back as string
let strArr = "12,12,43,53,56,7,854,3,64,35,24,67"
Please some one suggest me any solution
You can use toString() method:
let arr = [12,12,43,53,56,7,854,3,64,35,24,67];
arr = arr.toString();
console.log(arr);
console.log(typeof arr);
You can read more about this here.
The join() method joins all elements of an array (or an array-like object) into a string.
var a = [12,12,43,53,56,7,854,3,64,35,24,67];
a.join(); // '12,12,43,53,56,7,854,3,64,35,24,67'
Solution to this would be to use join()
let arr = [12,12,43,53,56,7,854,3,64,35,24,67]
let strArr = arr.join();
Second you be to use toString()
let arr = [12,12,43,53,56,7,854,3,64,35,24,67]
let strArr = arr.toString();
Because you want to join by a comma, they are basically identical, but join allow you to chose a value separator.
arr + ""