DEV Community

Cover image for Function(al) Thinking 🧠
Aoppman
Aoppman

Posted on

Function(al) Thinking 🧠

Since the beginning of my coding journey, JavaScript functions have been an uphill battle.

Though, as the weeks have gone on, little by little I have been able to get bits and pieces of basic function structure to stick inside my scrambled brain.
- This has been no little feat

It did not come in full, nor all at once. As I had to get flustered even further, to the point of total confusion before grasping the basic concept of functions.

Inevitably, without full understanding of the basic function expression, the course work dove straight in to more variations of JS functions. Such as...

  • Callback functions
  • Anonymous functions
  • Arrow functions ... etc.

In this blog post I'll start with further describing how we write a basic Javascript function.

Lets begin with basic JS function!

Functions are blocks of code that take in inputs, perform specific actions, and produce outputs.
JS Function

Here we see the function keyword and then a variable name "sum" which holds the value of the function. Next we have inputs such as "num1" and "num2" which are variables holding values of their own. By placing these values in the parentheses "()", we are passing them into the function as parameters to hold an argument. Then within the function body we have the action, which is to add the two values together using the (+) arithmetic operator. In return we will get the result of adding the two values, which is the output.

In my next few blog posts I will dive further into explain the other type of functions different ways they can be written.

Top comments (0)