javascript - Minifying for{} loops -


i've got javascript for {} loops use repeatedly throughout project, similar this:

for (var = 0; < things.length; i++) {     console.log(things[i]);     // may different in different areas of project } 

i minified code, loops take lot of minified code. there way shorten above code this:

loop {     console.log(things[i]);     // may different in different areas of project } 

probably not above, idea. appreciated :)

a jquery-ish way that:

function each(arr, func) {   ( var = 0; < arr.length; ++i ) {     func(arr[i]);   } } 

can called like:

each( things, function(thing) { console.log(thing); } ); 

or

each( things, function(thing) { console.log(thing); alert(thing); } ); 

etc.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -