Knockout js array IndexOf

What is IndexOf in KnockoutJs Array?

arrayIndexOf

Using ArrayIndexOf, find the matched items from array collection. If array items are matched then returns true otherwise returns false.

For Example filter an observable array collection using indexOf().

 var filterAnArrayByArrayIndexOf = function (Text) {
           try {
               var filterText = Text.toLowerCase();         
               if (!filterText) {
                   return selectionList();
               }
               else {
                   if (selectionList().length > 0) {
                       return ko.utils.arrayFilter(selectionList(), function (item) {
                           if (item.SelectionLabel.toLowerCase().indexOf(filterText) > -1 || item.SelectionDescription.toLowerCase().indexOf(filterText) > -1) {
                               return true;
                           }
                           else {
                              return false;
                           }
                       });
                   }
               }
           }
           catch (ex) {
               window.itk.utility.logExceptions(ex);
          }
  };
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^