Converting JavaScript Array To JSON Format

后端 未结 2 1306
滥情空心
滥情空心 2021-01-29 14:16

i have an array like this coming back response from the server:

[
    \"111\",
    \"1010\",
    \"111\",
    \"1010\",
    \"1010\"
]

i want t

2条回答
  •  不思量自难忘°
    2021-01-29 14:59

    You could map a short hand property.

    var array = ["111", "1010", "111", "1010", "1010"],
        result = array.map(branch => ({ branch }));
    
    console.log(result);

提交回复
热议问题