Please tell me how to write javascript below in coffeescript.
setTimeout(function(){
something(param);
}, 1000);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think it’s a useful convention for callbacks to come as the last argument to a function. This is usually the case with the Node.js API, for instance. So with that in mind:
Granted, this adds the overhead of an extra function call to every
setTimeoutyou make; but in today’s JS interpreters, the performance drawback is insignificant unless you’re doing it thousands of times per second. (And what are you doing setting thousands of timeouts per second, anyway?)Of course, a more straightforward approach is to simply name your callback, which tends to produce more readable code anyway (jashkenas is a big fan of this idiom):