Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

correct way to format a javascript function

Tags:

People also ask

What is the format of a function in JavaScript?

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, ...)

Which of the following statements is the correct way to define a function in JavaScript?

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.

What are the 3 types of functions in JavaScript?

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