Favorite Code Snippets
over 9 years ago from Conlin "Wuz" Durbin, f-f-frontend @ lessonly.com
I know this is Designer News, but most of us code at least a bit. I was curious what your favorite bit of code is. Something cool, elegant, or otherwise. Show us the code, tell us the language, and tell us why you like it. :D
var arr = [1,3,5,4,7,2,8,5,4,77,34,5,6]; arr.sort( (a,b) => ((a==b) ? 0 : (a>b) ? 1 : -1) ); console.log(arr);
This is a beautiful bit of Javascript. It will only work in Firefox (for the time being), because of the little arrows. They basically equate to function(). This sorts an array in one line, which is pretty neat.
Can't wait to see everyone else's code!
Cheers, Conlin
Login to Comment
You'll need to log in before you can leave a comment.
LoginRegister Today
New accounts can leave comments immediately, and gain full permissions after one week.
Register now