Я учусь JavaScript
, и я некоторое время искал об этом, и я не получил никакого ответа по этому поводу. У меня вопрос, есть ли какое-либо правило для определения ключа JSON
в JavaScript.
Например, в python
есть правило, определяющее dict: All the keys must be of an immutable data type such as strings, numbers, or tuples.
var json = {};
json[""] = "White space";
json[" "] = "Two white space";
var emptyJSON = {};
var emptyArray = [];
function a (){}
json[a] = "Function";
json[emptyJSON] = "Json";
json[emptyArray]= "Array";
//I don't know why this property whit an empty array does not appear when I console the json
console.log("Print the entire object =>", json);
//But it appears when I console the specific property
console.log("Print empty array property =>", json[emptyArray]);