Posts

Showing posts with the label for in

JavaScript For In Madness

Have you never instinctively written a for in loop like the next one, instantly correcting it since you need a variable to perform it? for(var k in {oops:null}){ // cool, got "k" here ... // now how do I get // the bloody "oops" value? } This quick post talks about above nonsense case providing a solution I will explain only if anybody will be interested about it, since (I am quite lazy and tired right now and ...) I think I've been able to solve the trick using almost every JavaScript bad practice :D Runtime Assigned For In Loop (function(self, Function){ // Another (C) WebReflection Silly Idea "use strict"; // Mit Style Weirdness var $o; self.o = function o($){ if(!$) self.o = $o; else { $o = self.o; self.o = Function( "$", "return function o(" + new Array(($.length || 0) + 1).join(",k").slice(1) + "){return $(arguments[0])}" ...