I saunter along the banks of some dark boundless ocean in the multiverse that is my mind. The gentle undulating waves that once lulled me into the depths of its waters, now burble to spur me back…


独家优惠奖金 100% 高达 1 BTC + 180 免费旋转

Javascript Functions

Functions are the building blocks of a Javascript program. A Function contains a set of statements which performs a specific task. The function is basically wrapping a piece of program in a value. A function can be defined either by Function declaration or as Function expression.

Function Declaration:

A function declaration has a function keyword followed by the name of the function. The list of arguments can be mentioned inside parenthesis followed by the body of the function.

function add(a,b) {

return a + b;


The add function above takes two values a and b as arguments and returns its sum.

Function Expressions:

A function can also be created by a function expression.

let add = function(a,b) {

return a + b;


Calling a Function :

The function definition does not execute it. It just creates a function and specifies what to do when the function is called. In order the execute the function, the function has to be called.


The above statement calls the already defined function add with parameters 5 and 10 and would return its sum as 15.

The prime difference between Function declaration and Function Expression is Function declaration is hoisted, which means when the JS code is compiled, function declarations are lifted to the top of their global scope no matter where the function is declared. The below program prints the value 10 to the console without any error although the function is called even before the function declaration.


function add(a,b) {

return a + b;


Add a comment

Related posts:

Perceptron hands on

The perceptron is the simplest form of a neural network. It consists of a layer of entries one neuron and one output. The entries are linked with the neuron in a way that each link has a weight. The…

Fury Whitepaper 2.0

Fury was originally released as a basic Monero clone that was forked off of the latest Monero code. The only two goals when we started were to have an anonymous coin that would take the best parts…

My experience with Oncell Systems

In the summer of 2018, I did some work for my Fathers former company called Oncell Systems. This was my first experience being inside of an office where there were about twenty employees working the…