Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例子:
var o = {'key': 'value'}; var key = 'key'; console.log('key' in o); //true console.log(key in o); //false
这个怎么做?=)
我建议:
o.hasOwnProperty(key);
JS 小提琴演示。
参考:
hasOwnProperty()
尝试hasOwnProperty:
hasOwnProperty