Tweet For Code #4

By  on  

You don't need a thousand lines of code to make a big difference in any coding language.  Oftentimes it's quite the opposite:  a few tiny code snippets can do a world of good and accomplish big things.  I asked my Twitter followers to tweet to me their favorite tiny snippets of code -- that's a bit difference to try to pack into 140 characters!  Here are my favorites from this round!

ES6 Array Initialization

Here are a few clever ways to initialize an array with ES6:

Short syntax for dynamic result!

Remove Wrapping HTML with inner/outerHTML

This neat little trick allows you to remove a wrapping element and re-parent the child in one operation.

Of course you would brick your event connections but this is a neat trick.

3D Body Elements

Want a 3D look at a page's elements?  Check out this sweet JavaScript snippet:

This is a really neat optical effect, though not the most practical of snippets.

YOLO!

Since `sudo` gives you the ultimate of powers, why not give it a YOLO alias?

Hilarious!

Thank you to everyone who participated, and keep your tiny snippets for the next Tweet for Code!

Recent Features

  • By
    fetch API

    One of the worst kept secrets about AJAX on the web is that the underlying API for it, XMLHttpRequest, wasn't really made for what we've been using it for.  We've done well to create elegant APIs around XHR but we know we can do better.  Our effort to...

  • By
    CSS @supports

    Feature detection via JavaScript is a client side best practice and for all the right reasons, but unfortunately that same functionality hasn't been available within CSS.  What we end up doing is repeating the same properties multiple times with each browser prefix.  Yuck.  Another thing we...

Incredible Demos

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!