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
    CSS Animations Between Media Queries

    CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...

  • By
    Responsive Images: The Ultimate Guide

    Chances are that any Web designers using our Ghostlab browser testing app, which allows seamless testing across all devices simultaneously, will have worked with responsive design in some shape or form. And as today's websites and devices become ever more varied, a plethora of responsive images...

Incredible Demos

Discussion

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