Monday, 19 August 2013

Minifying for{} loops

Minifying for{} loops

I've got some javascript for {} loops which I use repeatedly throughout
the project, they are all similar to this:
for (var i = 0; i < things.length; i++) {
console.log(things[i]);
// This may be different in different areas of the project
}
I minified the code, but the loops take up a lot of the minified code. Is
there a way to shorten the above code to something like this:
loop {
console.log(things[i]);
// This may be different in different areas of the project
}
Probably not the above, but you get the idea. Any help would be much
appreciated :)

No comments:

Post a Comment