使用CoffeeScript检查对象是否存在于对象中的最简单的方法
在CoffeeScript中,检查对象中是否存在关键字的最简单方法是什么?
key of obj  这key in obj编译成JavaScript的key in obj 。  (CoffeeScript在引用键时使用,以及in引用数组值时: val in arr将testingval是否在arr 。) 
 如果你想忽略对象的原型,那么jj的回答是正确的。 吉米的答案是正确的,如果你想忽略null或undefined键。 
'?' 操作员检查是否存在:
 if obj? # object is not undefined or null if obj.key? # obj.key is not undefined or null # call function if it exists obj.funcKey?() # chain existence checks, returns undefined if failure at any level grandChildVal = obj.key?.childKey?.grandChildKey # chain existence checks with function, returns undefined if failure at any level grandChildVal = obj.key?.childKey?().grandChildKey 
 obj.hasOwnProperty(name) 
(忽略inheritance的属性)