2

Writing a function in Javascript

 2 years ago
source link: https://dev.to/anjandutta/writing-a-function-in-javascript-35cf
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

What is a function

It is a way of writing a set of logic separately from the rest of the code. Functional coding is a clean, readable and reusable approach of programming.

It is also assigned a name for the ease of accessibility. Can we write functions without names? The answer is yes. We call those anonymous functions. I have discussed it later in this article.

Declaration of a function in Javascript

function name(parameter1, parameter2, ....) {
  statement1
  statement2

}
Enter fullscreen modeExit fullscreen mode

How to write a function in Javascript

A function declaration has three parts:

  • Parameters
  • Statements

Read more...


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK