A JavaScript function is defined with the function keyword, followed by a name, followed by parentheses (). Function names can contain letters, digits, underscores, and dollar signs (same rules as variables). The parentheses may include parameter names separated by commas: (parameter1, parameter2, ...)
The most common way to define a function in JavaScript is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces.
There are 3 ways of writing a function in JavaScript: Function Declaration. Function Expression. Arrow Function.
Just a quick one...
what's the correct way to format a javascript function?
I see it like this:
function doThis(){
}
and like this:
doThis = function(){
}
Or maybe it make no difference. Please let me know whats best or if they both have different rasons or purposes.
Cheers
C
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With