Chrome 开发者控制台正在 console.log
中执行此操作:
Your JSON sent is>> {yourVariable: "nothing yet"}
所以我知道 {yourVariable: "nothing Yet"}
JSON 对象中的值 "nothing Yet"
是一个字符串。但我如何知道yourVariable
键的类型?
有没有办法仅使用 Chrome 控制台来找到它?
最佳答案
所有对象键都是带引号或不带引号的字符串。试试这个方法看看吧。可能您对控制台打印感到困惑,因为控制台打印不带引号,而我们通常写带引号。
var jsonObj = {person:"me","age":"30", 123:"123"};
Object.keys(jsonObj).forEach(function(key){
console.log(typeof key)}
);
关于json - 此 JSON 对象 {yourVariable : "nothing yet"} 中的键的类型是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46127036/