I was inspired by the preview page in this article, showing how Douglas Adams may have wrote a function to list all of the primes less than or equal to a given number: http://arstechnica.com/information-technology/2014/11/holiday-reading-for-a-certain-sort-if-hemingway-wrote-javascript/Below is the code, but I also put it into a JSFiddle: http://jsfiddle.net/b38L4p9q/2/
//Here I am, brain the size of a planet, and they ask me to write JavaScript...function kevinTheNumberMentioner(_){ l=[] /* mostly harmless --> */ with(l) { //Sorry about all this, my babel fish has a headache today... for (ll=!+[]+!![];ll<_+(+!![]);ll++) { lll=+!![]; while (ll%++lll); //I've got this terrible pain in all the semicolons down my right-hand side. (ll==lll)&&push(ll); } forEach(alert); } //You're really not going to like this... return [!+[]+!+[]+!+[]+!+[]]+[!+[]+!+[]];}
function primeAlert(n) { 'use strict'; var arr = [], m, p; for (m = 2; m <= n; m++) { p = 1; while (m % ++p); if (m === p) arr.push(m); } arr.forEach(alert); return '42';}
function primeAlert(n) { 'use strict'; var arr, m, p, r; n = Math.floor(+n); if (n !== n || n < 2 || n >= Math.pow(2, 53)) return []; arr = []; for (m = 2; m < n; m++) { p = 1; r = Math.sqrt(m); while (m % ++p && p <= r); if (p > r) arr.push(m); } return arr;}
11/30/2014 2:29:09 AM
i see this as code snippet a professor would put up for us to laugh about then the class would move to efficient code writing and never show that shit again.
11/30/2014 7:42:14 AM
the fuck is wrong with you, op
11/30/2014 12:44:42 PM
[Edited on November 30, 2014 at 8:22 PM. Reason : *]
11/30/2014 8:21:10 PM
https://github.com/mbostock/d3/wiki/Treemap-LayoutSomething cool from JavaScript land, as a way to make amends for it's short comings.
12/3/2014 12:14:43 PM
^ Mike Bostock is a fucking dataviz wizard
12/17/2014 8:03:43 PM
hax teh planet: http://arstechnica.com/security/2014/12/meet-flashflood-the-lightweight-script-that-causes-websites-to-falter/https://www.youtube.com/watch?v=PmWDqX44I84all you need is XSS or social engineering
12/18/2014 7:28:23 AM
I think I learned why undefined will never be a reserved word; much like making typeof null return 'null' it would cause existing code to break, particularly jQuery: https://groups.google.com/d/topic/comp.lang.javascript/Mp5r0WrkyYo/discussion
12/29/2014 3:40:03 AM