Mozilla Developer Network :
[forEach callback] is called with three arguments:element valueitem indexarray passed
[forEach callback] is called with three arguments:
element value
item index
array passed
However, this is a little incomprehensible to me. Are all three arguments necessary? The specific callback I'm writing will not use any of these values. Am I announcing them anyway or can I safely skip them?
You can safely skip them.
. , - , .
, , - , - .
foo.addEventListener('click', function(evt) { //if I never reference the evt object, I need not define the evt argument }, false);
, javascript , . javascript - , , .
function a(arg1){ console.log(arg1); }
a
a(); // prints undefined a(1); // prints 1 a(1,2); // prints 1
.
, , undefined.
undefined
, , arguments
arguments
Source: https://habr.com/ru/post/1652760/More articles:Best way to check if a function is related to regular JavaScript? - javascriptHow to join multiple columns in one table? - javaCopy text and binary files with one function? - cCSS Background Triangle 3 colors - htmlΠ‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ API Ρ Firebase 3 - restGoogle Maps Activity Authorization Error - androidShould I add a Laravel provider directory to .gitignore or not? - gitBuild with buck on travis servers - c ++pytest-bdd reuse the same method for different stages - pythonionic 2 / cordova reads images from iOS document catalog - iosAll Articles