javascript - 将数组转换为没有键的对象
问题描述
我正在寻找一种方法来转换它。
const data = [{
id: 1,
fullnames: 'JosephSam',
weight: 1231,
currentdate: '2021-09-22'
}]
进入这个
const data = {
id: 1,
fullnames: 'JosephSam',
weight: 1231,
currentdate: '2021-09-22'
}
解决方案
const arr = [{
id: 1,
fullnames: 'JosephSam',
weight: 1231,
currentdate: '2021-09-22'
}];
const data = arr[0];
console.log(data.fullnames); // 'JosephSam'
这将是你所需要的。我确实觉得这不是你要找的。如果是这样,请给我们一个更复杂的例子,看看你在处理什么。
推荐阅读
- python - Python 将输入解释为数学函数
- aspnetboilerplate - ABP BoilerPlate:当我使用 UserFirendlyException 时,我看不到我的异常消息
- html - 标签附近输入复选框的XPath?
- c# - 以编程方式更改选定的 TabControl - WPF
- kubernetes - 如何将外部对等点连接到现有的 Hyperledger 结构(在 Kubernetes 上运行)?
- fortify - HP Fortify BIRTReportGenerator 仅获取新问题
- ssh - ssh 到谷歌云权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic)
- java - 来自多部分形式的 JAVA 图像请求
- reactjs - 表头未对齐,this.setState 在 ReactJS 的私有方法中不起作用
- swift - Swift 4 以编程方式设置自定义字体