My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Function love(for){JavaScript};

Akshat Gupta's photo
Akshat Gupta
·Dec 6, 2021·

2 min read

Function love(for){JavaScript};

So , as title suggests we are gonna talk about the JavaScript functions . One of the most powerful things about JavaScript is its functions and wrapping it inside value . Function is basically a binding/variable through which we can use the value for calculating values. function square(a){ return a*a; } The above function helps us to calculate square of a number . Function declaration can be done in many ways the above explained is one this a is the parameter which can be more than one or zero .Square was the function name. Various things regarding the functions declaration and other things are discussed below.

Bindings and Scopes

Each binding has the scope which determines that which binding can be accessed in different parts of program.

Global Scope

So when any binding can be accessed anytime in the program that binding is Global Binding.

Local Scope

So when any binding can be accessed inside a specific function they are known as Local Bindings.

Nested Scope

Its like creating a binding inside a function that can be accessed be the functions which are inside that function . For ex-

function arithmeticGames(){
let a=5;
let b=6;
function sum(){ return a+b}//return sum of a&b
function multiply{return a*b}//return multiplication of a&b
}
console.log(a,b)//undefined-reference type error

Functions and their Declarations

Two main ways to declare a functions are

Function keyword:

function declared(){}

Arrow Function:

const thisFunction=()=>{ }

Summary

The most amazing part of the JavaScript is Functions and the power it offers to us . We can do many calculations with the help of functions we can also pass functions as arguments to functions which is one of the most powerful things .