Javascript method parameters

Hi @all, I need help. I`m new to Javascript and want to train a littlebit. In my script I loop an array. This array has two identifiers and values. Let's say ID and Text. Now, I want to call a method and pass the line of the array. But without to pass each Identifier. I hope there is something like this: For(wa in array) { MyMethod(wa) }; MyMethod(wa) { Allert(wa.id); Allert(wa.text); }; Thanks Helge

9/26/2019 8:36:32 PM

Helge Hauffe

3 Answers

New Answer


You can try it like this: array.forEach(MyMethod); MyMethod(value, index, array){ Allert(value.id); Allert(value.text); };


it seems that with forEach I can only call functions and not methods of my class?!


Did you try calling function with this.functionName?