better existence test, with tests

This commit is contained in:
Jeremy Ashkenas
2010-01-01 12:41:55 -05:00
parent ff80f8d423
commit 75d9e23df4
2 changed files with 7 additions and 1 deletions

View File

@@ -724,7 +724,8 @@ module CoffeeScript
end
def compile(o={})
write("(#{@expression.compile(super(o))} != undefined)")
val = @expression.compile(super(o))
write("(typeof #{val} !== 'undefined' && #{val} !== null)")
end
end