existential-operator

How do I use the CoffeeScript existential operator to check some object properties for undefined?

北城以北 提交于 2019-12-01 15:20:11
I would like to use the CoffeeScript existential operator to check some object properties for undefined. However, I encountered a little problem. Code like this: console.log test if test? Compiles to: if (typeof test !== "undefined" && test !== null) console.log(test); Which is the behavior I would like to see. However, when I try using it against object properties, like this: console.log test.test if test.test? I get something like that: if (test.test != null) console.log(test.test); Which desn't look like a check against undefined at all. The only way I could have achieved the same (1:1)

How do I use the CoffeeScript existential operator to check some object properties for undefined?

我是研究僧i 提交于 2019-12-01 14:11:08
问题 I would like to use the CoffeeScript existential operator to check some object properties for undefined. However, I encountered a little problem. Code like this: console.log test if test? Compiles to: if (typeof test !== "undefined" && test !== null) console.log(test); Which is the behavior I would like to see. However, when I try using it against object properties, like this: console.log test.test if test.test? I get something like that: if (test.test != null) console.log(test.test); Which

How do I use the CoffeeScript existential operator to check some object properties for undefined?

回眸只為那壹抹淺笑 提交于 2019-11-27 11:49:24
I would like to use the CoffeeScript existential operator to check some object properties for undefined. However, I encountered a little problem. Code like this: console.log test if test? Compiles to: if (typeof test !== "undefined" && test !== null) console.log(test); Which is the behavior I would like to see. However, when I try using it against object properties, like this: console.log test.test if test.test? I get something like that: if (test.test != null) console.log(test.test); Which desn't look like a check against undefined at all. The only way I could have achieved the same (1:1)

How does CoffeeScript's existential operator work?

拈花ヽ惹草 提交于 2019-11-26 20:50:40
Coffeescript uses the existential operator to determine when a variable exists, and in the coffeescript documentation it shows that something? would compile to something !== undefined && something !== null however I noticed that my version of coffeescript was only compiling this to something !== null so I wrote a test to see how this would effect my code taco = undefined if taco? console.log "fiesta!" else console.log "No taco!" which compiled to // Generated by CoffeeScript 1.4.0 (function() { var taco; taco = void 0; if (taco != null) { console.log("fiesta!"); } else { console.log("No taco!"

How does CoffeeScript's existential operator work?

a 夏天 提交于 2019-11-26 07:45:03
问题 Coffeescript uses the existential operator to determine when a variable exists, and in the coffeescript documentation it shows that something? would compile to something !== undefined && something !== null however I noticed that my version of coffeescript was only compiling this to something !== null so I wrote a test to see how this would effect my code taco = undefined if taco? console.log \"fiesta!\" else console.log \"No taco!\" which compiled to // Generated by CoffeeScript 1.4.0