Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

JS question: does list have value

Participant ,
Sep 06, 2021 Sep 06, 2021

Good day honorable adobe forum members,

 

I am looking for the method to use to check if a value is in a list

 

i.e.:

 

var list = ["A","B","C"]

if ("a"  in list) {
//dothings
}

 

Hoe does one do this effectively?

 

Thank you in advance for any and all trouble to be taken

TOPICS
Acrobat SDK and JavaScript , Windows
465
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 06, 2021 Sep 06, 2021

Yes, using the indexOf method. See: https://www.w3schools.com/jsref/jsref_indexof_array.asp

 

Translate
Participant ,
Sep 06, 2021 Sep 06, 2021

I see I typed "a" instead of "A" , I hope this doesn't cause confusion (the example should say "A") 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 06, 2021 Sep 06, 2021

Yes, using the indexOf method. See: https://www.w3schools.com/jsref/jsref_indexof_array.asp

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Sep 09, 2021 Sep 09, 2021

Thank you try67, your presence on these boards is a godsend.

 

Thank you very much once more.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 09, 2021 Sep 09, 2021
LATEST

You're very welcome!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines