const fakeDataObj = fakeData2.reduce((obj, item) => Object.assign(obj, { [item.name]: item.valueOf() }), {})
const str = '4556' as string;
console.log(fakeDataObj['4556' as keyof typeof fakeDataObj]);
//back to array
const new array = []
for (const elem in fakeDataObj.data) {
newArray.push(fakeDataObj.data[elem as keyof typeof fakeDataObj.data])
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter