愚者樹屋

|
Home About Contact
|

series

3d軟體 (1) apache (1) css (4) godot (8) google-api (1) google翻譯 (1) html (6) hugo安裝 (7) javasciprt (1) javascript (14) jquery (3) mysql (9) notepad++ (1) php (33) python (1) unity (1) yt-dlp (1) 像素畫 (1) 免費軟體 (8) 壓力測試 (2) 弱點掃描修補 (1) 無障礙網站 (1) 社群網站 (1) 遊戲推薦 (4) 雜記 (1)

Tags

2d軟體 3d軟體 ai apache css godot google-api google翻譯 html hugo javasciprt javascript jquery mysql notepad++ php python tcpdf unity vroid

javascript 物件轉陣列

post date - 2023/12/09
last update - 2023/12/09

使用ajax時陣列資料傳送到前端時會呈現物件的狀態,這邊記錄一下將他轉換成array來使用的方式。

方法

下方紀錄兩種寫法都可以轉換

//物件資料
var obj = {"1":5,"2":7,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0}
//方法1
var result = Object.keys(obj).map((key) => [key, obj[key]]);
//方法2
var result = Object.entries(obj);

參考資料

https://stackoverflow.com/questions/38824349/how-to-convert-an-object-to-an-array-of-key-value-pairs-in-javascript

Tags : javascript

series

3d軟體 (1) apache (1) css (4) godot (8) google-api (1) google翻譯 (1) html (6) hugo安裝 (7) javasciprt (1) javascript (14) jquery (3) mysql (9) notepad++ (1) php (33) python (1) unity (1) yt-dlp (1) 像素畫 (1) 免費軟體 (8) 壓力測試 (2) 弱點掃描修補 (1) 無障礙網站 (1) 社群網站 (1) 遊戲推薦 (4) 雜記 (1)

Tags

2d軟體 3d軟體 ai apache css godot google-api google翻譯 html hugo javasciprt javascript jquery mysql notepad++ php python tcpdf unity vroid

Recent Posts

hugo發表文章

2022/05/08

mysql指定排序

2024/01/06

css 文字隱藏

2023/08/19

社群分享暫存資料更新

2022/08/06

將hugo網站放上github

2022/05/28

mastodon misskey pixiv plurk twitter 巴哈姆特

© 2022-2025 愚者樹屋