【发布时间】:2020-01-16 20:32:31
【问题描述】:
假设我有
A = [cat,dog,horse]
B = [angry,happy,sad]
call = {}
如何制作像这样的 json 对象
console.log(call.animal[2]) // horse
console.log(call.mood[2]) // sad
【问题讨论】:
-
call = { animal : A, mood : B}?或call = {}; call.animal = A; call.mood = B? -
您是在问如何将其转换为 JSON 或如何将两个数组合并为一个对象?阅读stackoverflow.com/questions/4215737/convert-array-to-object
标签: javascript json reactjs