SlideShare a Scribd company logo
Default Params | ES6
JAGADEESH PATTA ( PJ )
Agenda
 Introduction to Default Parameters
 Destructured params with Default Values.
 Evaluated Default params at function call.
 Live Example
Introduction
 Default function parameters allow formal parameters to be initialized with
default values if no value or undefined is passed from calling function.
 In JavaScript the default function parameter value is undefined.
Introduction(cont…)
Syntax
function function_name(param = default_value){
// function body.
}
Introduction(cont…)
Example
function getEmployeeDetails(empId = pj001){
return `The employee id is : ${ empId }`;
}
getEmployeeDetails(‘pj123’); // empId is pj123
getEmployeeDetails(); // here empId is pj001
Default Params – Destructured Params
 We can initialize default params using Destructured params.
Syntax
function function_name([param_1, param_2] = [val_1, val_2]){
// Function body.
}
Default Params – Destructured Params
Example
function getFullName([fName, lName] = [‘P’, ‘J’]){
return fName +” ”+ lName;
}
getFullName();
getFullName([‘Patta’,’Jagadeesh’]);
Default Params – Function call
 We can initialize default params by calling function calls.
Syntax
function function_name( param = function() ){
// Function body.
}
Default Params – Function call
Example
function getFullName( firstName = getLastName( ), lastName ){
return firstName + “ ” + lastName;
}
function getLastName() { return “emp”; }
getFullName( undefined, ‘PJ’ );
Any Q ?
Thank You
Ad

Recommended

Oracle PL sql 3
Oracle PL sql 3
Sergio Ronchi
 
Pre defined Functions in C
Pre defined Functions in C
Prabhu Govind
 
Pointers
Pointers
Samsil Arefin
 
User defined functions in C
User defined functions in C
Harendra Singh
 
User Defined Functions in C
User Defined Functions in C
RAJ KUMAR
 
16717 functions in C++
16717 functions in C++
LPU
 
PL/SQL
PL/SQL
Vaibhav0
 
Function in c++
Function in c++
Kumar
 
Functions in c++
Functions in c++
Maaz Hasan
 
C function presentation
C function presentation
Touhidul Shawan
 
Function
Function
jayesh30sikchi
 
Function
Function
Kathmandu University
 
Call by value and call by reference in java
Call by value and call by reference in java
sunilchute1
 
Functions in C
Functions in C
Shobhit Upadhyay
 
Functions in C - Programming
Functions in C - Programming
GaurangVishnoi
 
Functions
Functions
Low-Code Starter Pack
 
Function in C
Function in C
Dr. Abhineet Anand
 
functions of C++
functions of C++
tarandeep_kaur
 
Presentation on function
Presentation on function
Abu Zaman
 
user defined function
user defined function
King Kavin Patel
 
Function arguments In Python
Function arguments In Python
Amit Upadhyay
 
Functions in c
Functions in c
KavithaMuralidharan2
 
Functions in c++
Functions in c++
Abdullah Turkistani
 
Procedure n functions
Procedure n functions
Khadija Parween
 
Function
Function
rishabh agrawal
 
Function and types
Function and types
Sherin Fathima
 
Inline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
 
Function C++
Function C++
Shahzad Afridi
 
12. Map | WeakMap | ES6 | JavaScript | Typescript
12. Map | WeakMap | ES6 | JavaScript | Typescript
pcnmtutorials
 
11. Iterators | ES6 | JavaScript | TypeScript
11. Iterators | ES6 | JavaScript | TypeScript
pcnmtutorials
 

More Related Content

What's hot (20)

Functions in c++
Functions in c++
Maaz Hasan
 
C function presentation
C function presentation
Touhidul Shawan
 
Function
Function
jayesh30sikchi
 
Function
Function
Kathmandu University
 
Call by value and call by reference in java
Call by value and call by reference in java
sunilchute1
 
Functions in C
Functions in C
Shobhit Upadhyay
 
Functions in C - Programming
Functions in C - Programming
GaurangVishnoi
 
Functions
Functions
Low-Code Starter Pack
 
Function in C
Function in C
Dr. Abhineet Anand
 
functions of C++
functions of C++
tarandeep_kaur
 
Presentation on function
Presentation on function
Abu Zaman
 
user defined function
user defined function
King Kavin Patel
 
Function arguments In Python
Function arguments In Python
Amit Upadhyay
 
Functions in c
Functions in c
KavithaMuralidharan2
 
Functions in c++
Functions in c++
Abdullah Turkistani
 
Procedure n functions
Procedure n functions
Khadija Parween
 
Function
Function
rishabh agrawal
 
Function and types
Function and types
Sherin Fathima
 
Inline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
 
Function C++
Function C++
Shahzad Afridi
 

More from pcnmtutorials (18)

12. Map | WeakMap | ES6 | JavaScript | Typescript
12. Map | WeakMap | ES6 | JavaScript | Typescript
pcnmtutorials
 
11. Iterators | ES6 | JavaScript | TypeScript
11. Iterators | ES6 | JavaScript | TypeScript
pcnmtutorials
 
10. symbols | ES6 | JavaScript | TypeScript
10. symbols | ES6 | JavaScript | TypeScript
pcnmtutorials
 
9. ES6 | Let And Const | TypeScript | JavaScript
9. ES6 | Let And Const | TypeScript | JavaScript
pcnmtutorials
 
8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript
pcnmtutorials
 
7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript
pcnmtutorials
 
5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment
pcnmtutorials
 
4. Template strings | ES6
4. Template strings | ES6
pcnmtutorials
 
3. Object literals | ES6 | JSON
3. Object literals | ES6 | JSON
pcnmtutorials
 
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
pcnmtutorials
 
1. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES6
pcnmtutorials
 
Decorators | TypeScript | Angular2 Decorators
Decorators | TypeScript | Angular2 Decorators
pcnmtutorials
 
Web workers | JavaScript | HTML API
Web workers | JavaScript | HTML API
pcnmtutorials
 
Declaration merging | Typescript
Declaration merging | Typescript
pcnmtutorials
 
Module resolution | Typescript
Module resolution | Typescript
pcnmtutorials
 
Material design in android L developer Preview
Material design in android L developer Preview
pcnmtutorials
 
data structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 
1.introduction to data_structures
1.introduction to data_structures
pcnmtutorials
 
12. Map | WeakMap | ES6 | JavaScript | Typescript
12. Map | WeakMap | ES6 | JavaScript | Typescript
pcnmtutorials
 
11. Iterators | ES6 | JavaScript | TypeScript
11. Iterators | ES6 | JavaScript | TypeScript
pcnmtutorials
 
10. symbols | ES6 | JavaScript | TypeScript
10. symbols | ES6 | JavaScript | TypeScript
pcnmtutorials
 
9. ES6 | Let And Const | TypeScript | JavaScript
9. ES6 | Let And Const | TypeScript | JavaScript
pcnmtutorials
 
8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript
pcnmtutorials
 
7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript
pcnmtutorials
 
5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment
pcnmtutorials
 
4. Template strings | ES6
4. Template strings | ES6
pcnmtutorials
 
3. Object literals | ES6 | JSON
3. Object literals | ES6 | JSON
pcnmtutorials
 
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
pcnmtutorials
 
1. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES6
pcnmtutorials
 
Decorators | TypeScript | Angular2 Decorators
Decorators | TypeScript | Angular2 Decorators
pcnmtutorials
 
Web workers | JavaScript | HTML API
Web workers | JavaScript | HTML API
pcnmtutorials
 
Declaration merging | Typescript
Declaration merging | Typescript
pcnmtutorials
 
Module resolution | Typescript
Module resolution | Typescript
pcnmtutorials
 
Material design in android L developer Preview
Material design in android L developer Preview
pcnmtutorials
 
data structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 
1.introduction to data_structures
1.introduction to data_structures
pcnmtutorials
 
Ad

Recently uploaded (20)

FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc Webinar - 2025 Global Privacy Survey
TrustArc
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
“Addressing Evolving AI Model Challenges Through Memory and Storage,” a Prese...
Edge AI and Vision Alliance
 
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
June Patch Tuesday
June Patch Tuesday
Ivanti
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
High Availability On-Premises FME Flow.pdf
High Availability On-Premises FME Flow.pdf
Safe Software
 
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Floods in Valencia: Two FME-Powered Stories of Data Resilience
Safe Software
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Ad

6. Default parameters | ES6 | JavaScript

  • 1. Default Params | ES6 JAGADEESH PATTA ( PJ )
  • 2. Agenda  Introduction to Default Parameters  Destructured params with Default Values.  Evaluated Default params at function call.  Live Example
  • 3. Introduction  Default function parameters allow formal parameters to be initialized with default values if no value or undefined is passed from calling function.  In JavaScript the default function parameter value is undefined.
  • 5. Introduction(cont…) Example function getEmployeeDetails(empId = pj001){ return `The employee id is : ${ empId }`; } getEmployeeDetails(‘pj123’); // empId is pj123 getEmployeeDetails(); // here empId is pj001
  • 6. Default Params – Destructured Params  We can initialize default params using Destructured params. Syntax function function_name([param_1, param_2] = [val_1, val_2]){ // Function body. }
  • 7. Default Params – Destructured Params Example function getFullName([fName, lName] = [‘P’, ‘J’]){ return fName +” ”+ lName; } getFullName(); getFullName([‘Patta’,’Jagadeesh’]);
  • 8. Default Params – Function call  We can initialize default params by calling function calls. Syntax function function_name( param = function() ){ // Function body. }
  • 9. Default Params – Function call Example function getFullName( firstName = getLastName( ), lastName ){ return firstName + “ ” + lastName; } function getLastName() { return “emp”; } getFullName( undefined, ‘PJ’ );