Can you please interpret how these parameters (arguments) work in functions, I reread a lot of literature, English and Russian, I just don’t understand how it works, everything seems to be not difficult, but it’s these arguments that don’t get into my head at all. For example, I create a function:

function myFunc(a,b) { console.log(a+b); } 

and nicherta does not work, emphasizes to me both my arguments a and b, tried to do so

 function myFunc("Hello","World") 

and vseravno emphasizes these arguments and swears at them, can not determine (is not defined), please help who knows

  • 3
    The function word function needed when defining a function, when calling it is not. - Suvitruf

1 answer 1

Exactly these arguments in general do not climb into the head

Use others :)

 myFunc("Bye", "Alexander"); 

 function myFunc(a, b) { console.log(a + b); } myFunc("Hello", "World"); 

In my time, а and b in function myFunc(a, b) { ... } were called formal parameters, and the values ​​supplied to the myFunc("Hello","World") call were actual.

They always win them!

  • Thanks, but how do these parameters work, do I assign them with a number or a string, and just for example, I do a + b where a is 1 parameter and b 2 or how? How he identifies it, how he understands what I want to add up for example: function (1,2,3,4) {a + c} - Alex
  • Or can I just do function (a, c) {a + c} like this? - Alex
  • Did you read JS literature? - Alexander
  • Yes, I read for sure, I have everything going smoothly, I understand everything, but I can’t pull out this particular topic at all ( - Alex
  • Read the difference between the parameters of the function and the arguments - Alexander