I want to convert array to string & if array contain object then need to convert in string.
array = [
'a',
'b',
{ name: 'John doe', age: 25 }
]
My code:
const convertedArray = array.join(' ');
Output like below:
a b "{"name":"john", "age":22, "class":"mca"}"
classproperty should be created? From your snippet it's unclear. If you want to just convert object to string - you can useJSON.stringify(object)