Skip to content

Instantly share code, notes, and snippets.

@hojberg
Created December 12, 2011 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hojberg/1467112 to your computer and use it in GitHub Desktop.
Save hojberg/1467112 to your computer and use it in GitHub Desktop.
host[model.isNew() ? "destroy" : "render"]();
// vs
if (model.isNew()) host.destroy();
else host.render();
@juandopazo
Copy link

To be honest I usually write the first one, but I try to wrap it in its own method. For instance, I'd never go around writing widget[boolean ? 'show' : 'hide'](), I'll always try to write a toggle() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment