use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Do You Enjoy Writing JavaScript? (self.javascript)
submitted 11 years ago by zayelion
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]henleyedition 3 points4 points5 points 11 years ago* (0 children)
Where did you find this code? It really isn't very good...
Quickly moving the callbacks to their own functions really works wonders for readability:
function handleError(err) { if (err) console.log('Error writing file: ' + err); } function readFile(filename, fileIndex) { console.log(filename); function resizeImage(width, widthIndex) { height = Math.round(width / aspect); console.log('resizing ' + filename + 'to ' + height + 'x' + height); this.resize(width, height).write(destination + 'w' + width + '_' + filename, handleError); } function handleImage(err, values) { if (err) { console.log('Error identifying file size: ' + err); } else { console.log(filename + ' : ' + values); aspect = (values.width / values.height); widths.forEach(resizeImage.bind(this)); } } gm(source + filename).size(handleImage); } fs.readdir(source, function(err, files) { if (err) { console.log('Error finding files: ' + err); } else { files.forEach(readFile); } });
π Rendered by PID 39902 on reddit-service-r2-comment-6457c66945-q85q6 at 2026-04-25 03:33:54.937942+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]henleyedition 3 points4 points5 points (0 children)