检查键是否存在于JavaScript对象中? - Checking if a key exists in a JavaScript object?

问题:

How do I check if a particular key exists in a JavaScript object or array? 如何检查JavaScript对象或数组中是否存在特定键? 数组

If a key doesn't exist, and I try to access it, will it return false? 若是密钥不存在,而我尝试访问它,它将返回false吗? Or throw an error? 仍是抛出错误? spa


解决方案:

参考一: https://stackoom.com/question/4beK/检查键是否存在于JavaScript对象中
参考二: https://oldbug.net/q/4beK/Checking-if-a-key-exists-in-a-JavaScript-object