📌  相关文章
📜  检查字典中是否有键 javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:09.188000             🧑  作者: Mango

代码示例2
// We can check if an item or key exists by using a simple if statement.
// We will just provide the key to the if statement. 
// If the item or key exists the if block will be executed.

if(dict.name){
   console.log(dict.name);
}

if(dict[10]){
   console.log(dict[10]);
}