4 ms·
Am I the only one who thinks this is unreadable? var on = !afind($(id), collapsed()); (on ? addClass : remClass)($(id), 'coll'); where function a
by dandare 8y ago
Am I the only one who thinks this is unreadable?
var on = !afind($(id), collapsed());
(on ? addClass : remClass)($(id), 'coll');
where
function afind (x, a) { var i = apos(x, a); return (i >= 0) ? a[i] : null; }
where
function apos (x, a) { return (typeof x == 'function') ? posf(x,a) : Array.prototype.indexOf.call(a,x) }
where
function posf (f, a) { for (var i=0; i < a.length; i++) { if (f(a[i])) return i; } return -1; }
- Topgamer7 8y agoIt's not too descriptive, however it is descriptive by function name. Take the afind line, you can ascertain what it does by afind's name and provided params: afind -> find, $(id) -> find id, collapsed -> find id's collapsed state. I agree it's not a simple glance to figure out what it does, however it is not unreadable.
- deleted 8y ago[deleted]
- crazygringo 8y ago+1,000. The best programming advice I ever got was to write code for other people to read (and understand at a glance), not for the machine to execute. This code is the precise opposite of that.
- mandeepj 8y agoWhy it can't be both? And, Yes - it can
- deleted 8y ago[deleted]
- dang 8y agoIt is a precise embodiment of that: the code was written specifically for people to read, and those people find it very readable. It is a mistake to assume a single standard here. Does a German speaker find a Sanskrit text readable, or a trombone player find a guitar piece playable?