SlideShare a Scribd company logo
Presentation of java script Functions
Functions are one of the fundamental building
blocks in JavaScript. A function is a JavaScript
procedure a set of statements that performs a task or
calculates a value.
The function define is a regular binding where the
value of the binding is a function.
Defining a function
A function is created with an expression that starts
with the keyword function. Functions have set of
parameters and body, which contains the statements
that are to be executed when function is called. As in
example below
Cont..
A function can have multiple parameter or no
parameter at all. Parameters to a function behave
like regular bindings, but their initial values are
given by the caller of the function, not the code in
the function itself.
Binding and scopes
Each binding has a scope, which is the part of the
program in which the binding is visible. For binding
defined outside of any function or block, the scope
is whole program is know as global binding.
But binding created for function parameters of
declared inside a function can be reference only in
that function is know as local binding
Nested scope
JavaScript distinguishes not just global and local
binding only. Block and functions can be created inside
other block and functions, producing multiple degree
of locality. This set of binding is visible inside a block is
determined by the place of that block in the program
text. This approach to binding visibility is called lexical
scoping.
Function as values
We can use the function value as the other value.
A function values can do all the thing that other values can do.
It is possible to store a function values in a new binding, pass it
as an argument to a function and so on.
Similarly, a binding that holds a function is still just a regular
binding and can it not constant, be assigned a new value like
cont.
Declaration notation
There is a slightly shorter way to create a function binding.
When the function keyword is used at the start of a
statement, it works differently.
function square(x) {
return X*X;
}
this is a function declaration. The statement defines the
binding square and points it at the given function.
Arrow functions
Instead of function keyword, it uses an arrow (=>)
made up of equals and greater-than character.
Cont..
The arrow comes after the list of parameters and is followed by
the function’s body. When there is only one parameters we can
omit the parentheses around the parameters list.
The call stack
Once the function call is done then it will return to the main
program the main program should maintain the log from which
the function is called. The place where the computer stores this
context is the call of stack. Every time the function is called, the
current context is stored on the top of this stack. When function
is returns, it removes the top context from the stack and uses
the context to continue execution .
Cont..
Optional arguments
JavaScript is extremely broad-minded
about the number of arguments you pass
to a function. If you pass to many, the
extra ones are ignored. If you pass to few,
the missing parameters get assigned the
value undefined
Closure
The ability to treat functions as values, combined with
the fact that local binding are re-created every time a
function is called. This allowed both the instances of
the binding can still be accessed. This features –being
able to reference a specific instance of a local binding
in an enclosing scope is called closure.
example
Recursion
Cont..
A function that calls itself it recursive is know as recursion
The calling function and the called function is same in recursion

More Related Content

PPTX
Function Parameters
primeteacher32
 
PDF
Handout # 4 functions + scopes
NUST Stuff
 
PPTX
Functions
Septi Ratnasari
 
PDF
Php, mysq lpart3
Subhasis Nayak
 
PPT
Python Built-in Functions and Use cases
Srajan Mor
 
PPTX
Scala functions
Kunal Cholera
 
PPTX
Function
Saniati
 
Function Parameters
primeteacher32
 
Handout # 4 functions + scopes
NUST Stuff
 
Functions
Septi Ratnasari
 
Php, mysq lpart3
Subhasis Nayak
 
Python Built-in Functions and Use cases
Srajan Mor
 
Scala functions
Kunal Cholera
 
Function
Saniati
 

What's hot (20)

DOCX
C programming language working with functions 1
Jeevan Raj
 
PDF
Function arguments In Python
Amit Upadhyay
 
PPTX
Python Functions
Mohammed Sikander
 
PPTX
Functions in python slide share
Devashish Kumar
 
PDF
Functional JavaScript Fundamentals
Srdjan Strbanovic
 
PPT
Create and analyse programs
Dr. C.V. Suresh Babu
 
PPTX
FUNCTION CPU
Krushal Kakadia
 
PPTX
Python functions part12
Vishal Dutt
 
PPTX
Function in C Programming
Anil Pokhrel
 
PDF
Functions and tasks in verilog
Nallapati Anindra
 
PPTX
Inline Functions and Default arguments
Nikhil Pandit
 
PPTX
Function
rishabh agrawal
 
PDF
Notes: Verilog Part 5 - Tasks and Functions
Jay Baxi
 
PPTX
Function overloading
Ashish Kelwa
 
PDF
Basics of Functional Programming
Sartaj Singh
 
PPTX
INLINE FUNCTION IN C++
Vraj Patel
 
PPTX
PARAMETER PASSING MECHANISMS
Arpee Callejo
 
PPTX
Function overloading in c++
Learn By Watch
 
PPTX
Inline function in C++
Learn By Watch
 
C programming language working with functions 1
Jeevan Raj
 
Function arguments In Python
Amit Upadhyay
 
Python Functions
Mohammed Sikander
 
Functions in python slide share
Devashish Kumar
 
Functional JavaScript Fundamentals
Srdjan Strbanovic
 
Create and analyse programs
Dr. C.V. Suresh Babu
 
FUNCTION CPU
Krushal Kakadia
 
Python functions part12
Vishal Dutt
 
Function in C Programming
Anil Pokhrel
 
Functions and tasks in verilog
Nallapati Anindra
 
Inline Functions and Default arguments
Nikhil Pandit
 
Function
rishabh agrawal
 
Notes: Verilog Part 5 - Tasks and Functions
Jay Baxi
 
Function overloading
Ashish Kelwa
 
Basics of Functional Programming
Sartaj Singh
 
INLINE FUNCTION IN C++
Vraj Patel
 
PARAMETER PASSING MECHANISMS
Arpee Callejo
 
Function overloading in c++
Learn By Watch
 
Inline function in C++
Learn By Watch
 
Ad

Similar to Java script function (20)

PDF
Function in C++
Prof Ansari
 
PPTX
Learn more about the concepts Functions of Python
PrathamKandari
 
PPTX
use of Functions to write python program.pptx
rahulsinghsikarwar2
 
PDF
functions notes.pdf python functions and opp
KirtiGarg71
 
DOC
4. function
Shankar Gangaju
 
PPTX
04. WORKING WITH FUNCTIONS-2 (1).pptx
Manas40552
 
PDF
Chapter 11 Function
Deepak Singh
 
PPTX
11_Functions_Introduction.pptx javascript notes
tayyabbiswas2025
 
PPTX
FUNCTIONS IN R PROGRAMMING.pptx
SafnaSaff1
 
PDF
All chapters C++ - Copy.pdfyttttttttttttttttttttttttttttt
jacobdiriba
 
PDF
Starting Out With C++ From Control Structures To Objects 9th Edition Gaddis S...
lablegtaton
 
PPTX
C functions
University of Potsdam
 
PDF
Important JavaScript Concepts Every Developer Must Know
yashikanigam1
 
PDF
379008-rc217-functionalprogramming
Luis Atencio
 
DOCX
Introduction to c programming
AMAN ANAND
 
PDF
Starting Out With C++ From Control Structures To Objects 9th Edition Gaddis S...
sekemioxiel
 
PDF
Functions-Computer programming
nmahi96
 
PPTX
functions.pptx
KavithaChekuri3
 
Function in C++
Prof Ansari
 
Learn more about the concepts Functions of Python
PrathamKandari
 
use of Functions to write python program.pptx
rahulsinghsikarwar2
 
functions notes.pdf python functions and opp
KirtiGarg71
 
4. function
Shankar Gangaju
 
04. WORKING WITH FUNCTIONS-2 (1).pptx
Manas40552
 
Chapter 11 Function
Deepak Singh
 
11_Functions_Introduction.pptx javascript notes
tayyabbiswas2025
 
FUNCTIONS IN R PROGRAMMING.pptx
SafnaSaff1
 
All chapters C++ - Copy.pdfyttttttttttttttttttttttttttttt
jacobdiriba
 
Starting Out With C++ From Control Structures To Objects 9th Edition Gaddis S...
lablegtaton
 
Important JavaScript Concepts Every Developer Must Know
yashikanigam1
 
379008-rc217-functionalprogramming
Luis Atencio
 
Introduction to c programming
AMAN ANAND
 
Starting Out With C++ From Control Structures To Objects 9th Edition Gaddis S...
sekemioxiel
 
Functions-Computer programming
nmahi96
 
functions.pptx
KavithaChekuri3
 
Ad

Recently uploaded (20)

PDF
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
CDH. pptx
AneetaSharma15
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PDF
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PPTX
FSSAI (Food Safety and Standards Authority of India) & FDA (Food and Drug Adm...
Dr. Paindla Jyothirmai
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
Study Material and notes for Women Empowerment
ComputerScienceSACWC
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
Miraj Khan
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
CDH. pptx
AneetaSharma15
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
FSSAI (Food Safety and Standards Authority of India) & FDA (Food and Drug Adm...
Dr. Paindla Jyothirmai
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 

Java script function

  • 1. Presentation of java script Functions Functions are one of the fundamental building blocks in JavaScript. A function is a JavaScript procedure a set of statements that performs a task or calculates a value. The function define is a regular binding where the value of the binding is a function.
  • 2. Defining a function A function is created with an expression that starts with the keyword function. Functions have set of parameters and body, which contains the statements that are to be executed when function is called. As in example below
  • 3. Cont.. A function can have multiple parameter or no parameter at all. Parameters to a function behave like regular bindings, but their initial values are given by the caller of the function, not the code in the function itself.
  • 4. Binding and scopes Each binding has a scope, which is the part of the program in which the binding is visible. For binding defined outside of any function or block, the scope is whole program is know as global binding. But binding created for function parameters of declared inside a function can be reference only in that function is know as local binding
  • 5. Nested scope JavaScript distinguishes not just global and local binding only. Block and functions can be created inside other block and functions, producing multiple degree of locality. This set of binding is visible inside a block is determined by the place of that block in the program text. This approach to binding visibility is called lexical scoping.
  • 6. Function as values We can use the function value as the other value. A function values can do all the thing that other values can do. It is possible to store a function values in a new binding, pass it as an argument to a function and so on. Similarly, a binding that holds a function is still just a regular binding and can it not constant, be assigned a new value like
  • 8. Declaration notation There is a slightly shorter way to create a function binding. When the function keyword is used at the start of a statement, it works differently. function square(x) { return X*X; } this is a function declaration. The statement defines the binding square and points it at the given function.
  • 9. Arrow functions Instead of function keyword, it uses an arrow (=>) made up of equals and greater-than character.
  • 10. Cont.. The arrow comes after the list of parameters and is followed by the function’s body. When there is only one parameters we can omit the parentheses around the parameters list.
  • 11. The call stack Once the function call is done then it will return to the main program the main program should maintain the log from which the function is called. The place where the computer stores this context is the call of stack. Every time the function is called, the current context is stored on the top of this stack. When function is returns, it removes the top context from the stack and uses the context to continue execution .
  • 13. Optional arguments JavaScript is extremely broad-minded about the number of arguments you pass to a function. If you pass to many, the extra ones are ignored. If you pass to few, the missing parameters get assigned the value undefined
  • 14. Closure The ability to treat functions as values, combined with the fact that local binding are re-created every time a function is called. This allowed both the instances of the binding can still be accessed. This features –being able to reference a specific instance of a local binding in an enclosing scope is called closure.
  • 17. Cont.. A function that calls itself it recursive is know as recursion The calling function and the called function is same in recursion