ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 1 使用 Object.keys() ``` var a = {a:1,b:2} Object.keys(a) //(2) ["a", "b"] var a = {a:1,b:2,c:{d:4,f:5}} Object.keys(a) //(3) ["a", "b", "c"] ``` ## 2 使用遍历 ``` var a = {a:1,b:2} var keys = [] for(key in a) keys.push(key) keys // (3) ["a", "b", "c"] ```