node.js - strange behavior of coffeescript compiler

Posted by JimBob on Stack Overflow See other posts from Stack Overflow or by JimBob
Published on 2012-11-19T23:58:16Z Indexed on 2012/11/20 5:00 UTC
Read the original article Hit count: 180

Filed under:
|

I noticed an unexplainable behavior of the coffeescript compiler for me :)

For example:

getImage: (req, res) =>
    realty_id = req.query.id

    if (realty_id?)

Result

ImageController.prototype.getImage = function(req, res) {
    var realty_id,
        _this = this;
      realty_id = req.query.id;
      if ((realty_id != null)

But actually the last line should be: if ((typeof realty_id !== "undefined" && realty_id !== null))

When I comment out "realty_id = req.query.id" it works well. Has anyone a explanation for that?

© Stack Overflow or respective owner

Related posts about node.js

Related posts about coffeescript