This is sample code. I want to break (or continue) knockout’s ko.util.arrayForEach.
ko.utils.arrayForEach(items, function (item) {
if (...) break;
if (...) continue;
}
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.
Looks like you can’t. Here’s the source of arrayForEach (from utils.js on the KO GitHub page)
However Knockout provides
ko.utils.arrayFirstthat will execute a function against each item in our array and return the first item where the function evaluates to true. Similar to the filteredItems computed observable, we can create one that returns the first match from our search field:More details can be found here http://www.knockmeout.net/2011/04/utility-functions-in-knockoutjs.html