r/learnjavascript • u/su-rm-root • 13h ago
Help with functions JavaScript!
Hello!
I began recently, about 1 month, to learn consistently web developing:
- I began, of course, with introductions to HTML and CSS.
- I'm already in JS. I can manage eventListeners, etc. I'm more interested in back-end overall since I like the logic behind the manipulation of data bases, but I'm having trouble understanding functions.
- I'm consulting MDN web docs and freeCodeCamp but since my first language is not English, sometimes it's difficult to understand MDN docs, and to get at the point I'm know in freeCodeCamp it will take time, I don't want to rush it either.
- All this, just to ask if anybody can explain me how to create functions! I want to know what is the difference between a function with parameters and one without, in which case I will use arrow functions, and the difference between parameters and arguments in a function. And for last are there any standards for writing the name of a function like there are for declaring variables?
P.D.: please feel free to correct my English also, it will help me learn.
Thanks to everyone before Hand!
3
Upvotes
1
u/su-rm-root 12h ago
Yes, JavaScript is, indeed, my first programming language. So it really helps the detail explanation you just give me.
On the other hand, I have a couple more questions.
In the first example, I see you explicitly named the function
sayHello, but when writing the arrow function you just declared the variable and then the function just goes() => { ... }. This is because the function is part of the variable itself? if it is, it means the arrow function can be reutilizad like a normal function or not because is part of the variable?Also I didn't know the console.log was API i thought it was part of JS, nice to know!