array of string to array of objects javascript code example
Example 1: javascript object to array
//ES6 Object to Array
const numbers = {
one: 1,
two: 2,
};
console.log(Object.values(numbers));
// [ 1, 2 ]
console.log(Object.entries(numbers));
// [ ['one', 1], ['two', 2] ]
Example 2: convert array of string to array of objects javascript
myArray = myArray.map((str, index) => ({ value: str, id: index + 1 }));
Example 3: javascript to array
Array.from("Hello"); // ["H", "e", "l", "l", "o"]