0
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
3 Respuestas
+ 1
You can try it like this:
array.forEach(MyMethod);
MyMethod(value, index, array){
Allert(value.id);
Allert(value.text);
};
0
it seems that with forEach I can only call functions and not methods of my class?!
0
Did you try calling function with
this.functionName?