Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 3
    Another thing we sometimes do in H5BP is introduce clever tricks like this that lead to a better understanding of code. I think this is a good example. The if statement is almost TOO obvious; it can afford to teach you something at the same time. Commented Apr 10, 2012 at 4:40
  • 3
    Any javascript programmer worth their salt will be able to read both forms equally well. When it comes to inline code, I typically prefer the shortest reasonable form, so I would use window.jQuery||document.write... for sake of brevity. Commented Apr 10, 2012 at 14:41
  • 3
    @PaulIrish I can't tell whether it's sarcasm or not. Commented Apr 10, 2012 at 19:41
  • So the idea is to teach a trick. -legitimate- but H5BP puts a stamp on everything saying essentially this ok, often probably being interpreted as the recommended way. (For H5BP) it's a matter of what's most valued - I say K.I.S.S. I vouch for stupid simple code that is really obvious. Either way developers are learning how to do a local fallback, eliminating clutter around how to do that I think would be best. Local fallback is a good trick. Short circuit statements, bad trick. Teach only good tricks? Commented Apr 10, 2012 at 19:43
  • Doesn't directly address this, but see javascript.crockford.com/style2.html Commented Jan 16, 2013 at 22:30