Skip to content

Instantly share code, notes, and snippets.

@bebraw
Created December 29, 2010 15:45
Show Gist options
  • Save bebraw/758651 to your computer and use it in GitHub Desktop.
Save bebraw/758651 to your computer and use it in GitHub Desktop.
// original
for(e,l='article aside footer header nav section time'.split(' ');e=l.pop();document.createElement(e))
// original + moved pop
for(l='article aside footer header nav section time'.split(' ');;document.createElement(l.pop()))
// mine (not tested! might need some braces...)
// v1 (no globals)
var l=['article','aside','footer','header','nav','section','time'];for(var i in l)document.createElement(l[i])
// v2 (globals)
l=['article','aside','footer','header','nav','section','time'];for(i in l)document.createElement(l[i])
@bebraw
Copy link
Author

bebraw commented Dec 29, 2010

True. Just figured out you can probably refactor "e" out of the original version. Just pop at createElement.

@hagenburger
Copy link

You may want to avoid endless loops.

@bebraw
Copy link
Author

bebraw commented Dec 29, 2010

Oh. Gotcha! Man, I need to test these things... :)

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