Skip to content

Instantly share code, notes, and snippets.

@joneath
Created May 6, 2012 05:42
Show Gist options
  • Save joneath/2618020 to your computer and use it in GitHub Desktop.
Save joneath/2618020 to your computer and use it in GitHub Desktop.
CoffeeScript Typeof Ternary what?
# CoffeeScript version
params[@options.param] = if model[@options.untilAttr]?() then model[@options.untilAttr]() else model.get(@options.untilAttr)
# Compiled version
params[_this.options.param] = (typeof model[_name = _this.options.untilAttr] === "function" ? model[_name]() : void 0) ? model[_this.options.untilAttr]() : model.get(_this.options.untilAttr);
# Original JS version
params[self.options.param] = typeof(model[self.options.untilAttr]) === "function" ? model[self.options.untilAttr]() : model.get(self.options.untilAttr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment