• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

JavaScript array and Contains

My attached script works.

My question really about how the JavaScript array.contains works.

Does "contains" mea that if  (sourceDetail) = "P01-Reg" that it will see that as a "True" in the contains just the same as if it is = P01?
arrValues = ["ALL", "P01", "P02"]
if (mymessage == "LT" && (arrValues.contains(afsSourceDetail))) {
    args.set_cancel(!confirm("Are you sure you want to split taxes? afsSource: " + afsSource));
    selectedRows.clear;
}

Open in new window

0
lrbrister
Asked:
lrbrister
  • 2
1 Solution
 
leakim971PluritechnicianCommented:
>Does "contains" mea that if  (sourceDetail) = "P01-Reg" that it will see that as a "True" in the contains just the same as if it is = P01?

The answer is no if you're using the following :

this[ i ]== element
0
 
leakim971PluritechnicianCommented:
Array.prototype.contains = function (element) 
  {
          for (var i = 0; i < this.length; i++) 
       {
              if (this[i] == element) 
          {
                      return true;
              }
          }
          return false;
  };

Open in new window

0
 
lrbristerAuthor Commented:
Thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now