In JavaScript, would it be wrong to create a function like:
//Loop to end
function loopToEnd(values, code){
for(var i=0; i < values.length; i++){code};
}
Or would this be unreasonable?
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.
Not unreasonable, although I’d have to assume that
codeis a function taking at the very least the object of iteration, and possibly an index. Most JS libraries have this, like jQuery’seach. Its function takes the index and object of iteration; see a jsfiddle example.