Sign in
Log inSign up

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 .

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct