SlideShare a Scribd company logo
5
Most read
7
Most read
9
Most read
WEEKLY PRESENTATION
DURING TRAINING PROGRAM
- Devang Garach
devanggarach.rao@gmail.com
WEEK-4
Information Technology
AGENDA
JavaScript Introduction
JavaScript Variable Declaration
JavaScript Data Types
JavaScript Objects
JavaScript Classes
JavaScript Hoisting
JavaScript Promises
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Introduction
JavaScript is a lightweight interpreted, client side scripting language, high
level loosely typed dynamic language.
Introduced by Netscape in 1995
To Add JavaScript into webpage, there are two ways Internal and External
under <script> tags.
JavaScript errors are silently ignored by the browsers, to know errors we
can use browser console debugging, to open console in browser press F12
key in keyboard.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Variables Declaration
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
We can declare variables in JavaScript by var keyword.
var a = 12 //number 12
var a = 12+”a”//String 12a
var check=true //boolean true
let b = 12 /number 12
const size=100 //number 100
JavaScript Variables Declaration (Difference between let, var ,constant)
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
var let const
It is available right from
the beginning when the
JavaScript was introduced
It is a new way to declare
variables in JavaScript,
starting from ES6 or
ECMAScript 2015
const is used to store a
value that will not be
changed throughout the
execution of the script, it is
also introduced with ES6
It has a global/ function
scope
It has block scope It also has block scope
Can be updated or re-
declared in its scope
We can't re-declare them const represent a const
value, so it can't be
updated or re-declared
JavaScript Data Types
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
In JavaScript there are 5 different data types that we can contain values
- string
- number
- boolean
- object
- function
There are 3 types of object
- Object, Date , Array
and 2 data types that cannot contain values:
- null and undefined
JavaScript Object
JavaScript is designed on a simple object-based paradigm. An object is a
collection of properties, and a property is an association between a name (or
key) and a value. A property's value can be a function, in which case the
property is known as a method.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
(Source : w3school.com)
JavaScript Object (Continue...)
To declare objects, The values are written as name:value pairs (name and
value separated by a colon).
var car = {type:"Fiat", model:"500", color:"white"};
var person = { firstName: "John",
lastName : "Doe",
id : 5566,
fullName : function() {
return this.firstName + " " + this.lastName;
}
};
Also by using New Keyword we can create object ot String, Number, Boolean...
object
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Class
JavaScript Class were introduced in ES6
JavaScript Class Syntax
Use the keyword class to create a class.
Always add a method named constructor() and methods:
class ClassName {
constructor() { ... }
method_1() { ... }
method_2() { ... }
method_3() { ... }
}
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Class (Continue...)
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
age(x) {
return x - this.year;}
}
let date = new Date();
let year = date.getFullYear();
let myCar = new Car("Ford",2014);
document.getElementById("demo").innerHTML= "My car is " + myCar.age(year) +
" years old.";
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Hoisting
Hoisting is JavaScript's default behavior of moving declarations to the top
In JavaScript, a variable can be declared after it has been used. In other
words; a variable can be used before it has been declared
Not only variables but also function declarations are moved to the top of
their scope before code execution
JavaScript only hoists declarations, not initializations.
Example:
x = 5; // Assign 5 to x
elem = document.getElementById("demo"); // Find an element
elem.innerHTML = x; // Display x in the element
var x; // Declare x
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Promises
As we all know that JavaScript is an asynchronous scripting language.
Promises are used to handle asynchronous operations in JavaScript. They
are easy to manage when dealing with multiple asynchronous operations
where callbacks can create callback hell leading to unmanageable code.
Benefits of Promises
● Improves Code Readability
● Better handling of asynchronous operations
● Better flow of control definition in asynchronous logic
● Better Error Handling
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Promises (Continue...)
A Promise has four states:
● fulfilled: Action related to the promise succeeded
● rejected: Action related to the promise failed
● pending: Promise is still pending i.e not fulfilled or rejected yet
● settled: Promise has fulfilled or rejected
A promise can be created using Promise constructor.
Syntax:
var promise = new Promise(function(resolve, reject){
//do something
}
);
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Promises (Continue...)
Promise Consumers:
Promises can be consumed by registering functions using .then and .catch methods.
then() is invoked when a promise is either resolved or rejected.
Parameters: then() method takes two functions as parameters. Success or Error.
Example:
var promise = new Promise(function(resolve, reject) {
resolve('Geeks For Geeks');
})
promise.then(
function(successMessage) {
//success handler function is invoked
console.log(successMessage);
}, function(errorMessage) {
console.log(errorMessage);
})
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Promises (Continue...)
Promises Methods:
Promise.all([array])
If the returned promise resolves, it is resolved with an aggregating array of
the values from the resolved promises, in the same order as defined in the
iterable of multiple promises. If it rejects, it is rejected with the reason from
the first promise in the iterable that was rejected.
Promise.allSettled()
Wait until all promises have settled (each may resolve or reject). Returns a
Promise that resolves after all of the given promises have either resolved or
rejected, with an array of objects that each describe the outcome of each
promise.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
JavaScript Promises (Continue...)
Promises Methods:
Promise.any():
Takes an iterable of Promise objects and, as soon as one of the promises in
the iterable fulfills, returns a single promise that resolves with the value
from that promise.
Promise.finally() - finally is an instance method like then() , catch()
Appends a handler to the promise, and returns a new promise that is
resolved when the original promise is resolved. The handler is called when
the promise is settled, whether fulfilled or rejected.
Information Technology
DURING TRAINING PROGRAM - WEEKLY PRESENTATION
Information Technology
Thank You.
- Devang Garach
devanggarach.rao@gmail.com

More Related Content

PDF
SlideShareの使い方 登録編
itno
 
PDF
ゲーム開発者のための C++11/C++14
Ryo Suzuki
 
ODT
Testing in-python-and-pytest-framework
Arulalan T
 
PPTX
Mopcon 2021 Scrum 是新的死亡行軍嗎?
Jen-Chieh Ko
 
PPTX
The adversary playbook - the tools, techniques and procedures used by threat ...
Jisc
 
PDF
DATA FLOW DIAGRAMS AND USER STORIES.pdf
RatheshCD
 
PDF
BDD in Action - building software that matters
John Ferguson Smart Limited
 
PDF
Form認証で学ぶSpring Security入門
Ryosuke Uchitate
 
SlideShareの使い方 登録編
itno
 
ゲーム開発者のための C++11/C++14
Ryo Suzuki
 
Testing in-python-and-pytest-framework
Arulalan T
 
Mopcon 2021 Scrum 是新的死亡行軍嗎?
Jen-Chieh Ko
 
The adversary playbook - the tools, techniques and procedures used by threat ...
Jisc
 
DATA FLOW DIAGRAMS AND USER STORIES.pdf
RatheshCD
 
BDD in Action - building software that matters
John Ferguson Smart Limited
 
Form認証で学ぶSpring Security入門
Ryosuke Uchitate
 

What's hot (20)

PDF
GDC2011 - Implementation and Application of the Real-Time Helper-Joint System
Jubok Kim
 
PPTX
Mini Project PPT
Faiz Ahmad Khan
 
PDF
使用 Pytest 進行單元測試 (PyCon TW 2021)
Max Lai
 
PDF
Unityネットワーク通信の基盤である「RPC」について、意外と知られていないボトルネックと、その対策法
モノビット エンジン
 
PPTX
Real-world game development with Ebitengine - How to make the best-selling G...
Daigo Sato
 
PPTX
Detection of Fake reviews
27DuddeSai
 
PPTX
ゲームエンジニアのためのデータベース設計
sairoutine
 
PDF
2015/11/15 Javaでwebアプリケーション入門
Asami Abe
 
PDF
Py.test
soasme
 
PPTX
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
DongMin Choi
 
PDF
[NDC 2018] 유체역학 엔진 개발기
Chris Ohk
 
PPTX
C# コンパイラーの書き換え作業の話
信之 岩永
 
PDF
ジェネレーティブAIと完全自動化がもたらす製造業の未来
IoTビジネス共創ラボ
 
PDF
劇的改善 Ci4時間から5分へ〜私がやった10のこと〜
aha_oretama
 
PPTX
GitLab CI/CD パイプライン
Tetsurou Yano
 
PDF
きつねさんでもわかるLlvm読書会 第2回
Tomoya Kawanishi
 
PDF
김민욱, (달빛조각사) 엘릭서를 이용한 mmorpg 서버 개발, NDC2019
min woog kim
 
PPT
Detection of plant diseases
Muneesh Wari
 
PDF
怖くないSpring Bootのオートコンフィグレーション
土岐 孝平
 
PDF
誰もAddressableについて語らないなら、自分が語るしかない…ッッッッ
Tatsuhiko Yamamura
 
GDC2011 - Implementation and Application of the Real-Time Helper-Joint System
Jubok Kim
 
Mini Project PPT
Faiz Ahmad Khan
 
使用 Pytest 進行單元測試 (PyCon TW 2021)
Max Lai
 
Unityネットワーク通信の基盤である「RPC」について、意外と知られていないボトルネックと、その対策法
モノビット エンジン
 
Real-world game development with Ebitengine - How to make the best-selling G...
Daigo Sato
 
Detection of Fake reviews
27DuddeSai
 
ゲームエンジニアのためのデータベース設計
sairoutine
 
2015/11/15 Javaでwebアプリケーション入門
Asami Abe
 
Py.test
soasme
 
[NDC 2018] 신입 개발자가 알아야 할 윈도우 메모리릭 디버깅
DongMin Choi
 
[NDC 2018] 유체역학 엔진 개발기
Chris Ohk
 
C# コンパイラーの書き換え作業の話
信之 岩永
 
ジェネレーティブAIと完全自動化がもたらす製造業の未来
IoTビジネス共創ラボ
 
劇的改善 Ci4時間から5分へ〜私がやった10のこと〜
aha_oretama
 
GitLab CI/CD パイプライン
Tetsurou Yano
 
きつねさんでもわかるLlvm読書会 第2回
Tomoya Kawanishi
 
김민욱, (달빛조각사) 엘릭서를 이용한 mmorpg 서버 개발, NDC2019
min woog kim
 
Detection of plant diseases
Muneesh Wari
 
怖くないSpring Bootのオートコンフィグレーション
土岐 孝平
 
誰もAddressableについて語らないなら、自分が語るしかない…ッッッッ
Tatsuhiko Yamamura
 
Ad

Similar to Brief Introduction on JavaScript - Internship Presentation - Week4 (20)

PDF
Advanced JavaScript - Internship Presentation - Week6
Devang Garach
 
PDF
internet Chapter 4-JavascripPrepare a ppt of video compression techniques bas...
wabii3179com
 
PPTX
Java script basic
Ravi Bhadauria
 
PPTX
Javascriptinobject orientedway-090512225827-phpapp02
Sopheak Sem
 
PDF
JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
Ch3- Java Script.pdf
HASENSEID
 
ODP
Presentation - Course about JavaFX
Tom Mix Petreca
 
PPTX
JavaScript- Functions and arrays.pptx
Megha V
 
PPTX
Java script
Shyam Khant
 
PPTX
wp-UNIT_III.pptx
GANDHAMKUMAR2
 
PPTX
IWT presentation121232112122222225556+556.pptx
dgfs55437
 
PPTX
Java script best practices v4
Thor Jørund Nydal
 
DOCX
Unit 2.4
Abhishek Kesharwani
 
PDF
CSS-three years solved model paper msbte
vemulasairaj10
 
PDF
[2015/2016] JavaScript
Ivano Malavolta
 
PDF
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
sharvaridhokte
 
PPTX
Java script
Rajkiran Mummadi
 
PDF
Important JavaScript Concepts Every Developer Must Know
yashikanigam1
 
PDF
379008-rc217-functionalprogramming
Luis Atencio
 
Advanced JavaScript - Internship Presentation - Week6
Devang Garach
 
internet Chapter 4-JavascripPrepare a ppt of video compression techniques bas...
wabii3179com
 
Java script basic
Ravi Bhadauria
 
Javascriptinobject orientedway-090512225827-phpapp02
Sopheak Sem
 
JavaScript Interview Questions PDF By ScholarHat
Scholarhat
 
Ch3- Java Script.pdf
HASENSEID
 
Presentation - Course about JavaFX
Tom Mix Petreca
 
JavaScript- Functions and arrays.pptx
Megha V
 
Java script
Shyam Khant
 
wp-UNIT_III.pptx
GANDHAMKUMAR2
 
IWT presentation121232112122222225556+556.pptx
dgfs55437
 
Java script best practices v4
Thor Jørund Nydal
 
CSS-three years solved model paper msbte
vemulasairaj10
 
[2015/2016] JavaScript
Ivano Malavolta
 
22519 - Client-Side Scripting Language (CSS) chapter 1 notes .pdf
sharvaridhokte
 
Java script
Rajkiran Mummadi
 
Important JavaScript Concepts Every Developer Must Know
yashikanigam1
 
379008-rc217-functionalprogramming
Luis Atencio
 
Ad

More from Devang Garach (8)

PDF
AWS Concepts - Internship Presentation - week 10
Devang Garach
 
PDF
A glimpse inside of SEO - Internship Presentation - week 9
Devang Garach
 
PDF
Machine Learning and its types - Internship Presentation - week 8
Devang Garach
 
PDF
Fundamental of Node.JS - Internship Presentation - Week7
Devang Garach
 
PDF
Overview of React.JS - Internship Presentation - Week 5
Devang Garach
 
PDF
Intro to HTML, CSS & JS - Internship Presentation Week-3
Devang Garach
 
PDF
Basics of Linux Commands, Git and Github
Devang Garach
 
PDF
M.C.A. Internship Project Presentation - Devang Garach [191823011]
Devang Garach
 
AWS Concepts - Internship Presentation - week 10
Devang Garach
 
A glimpse inside of SEO - Internship Presentation - week 9
Devang Garach
 
Machine Learning and its types - Internship Presentation - week 8
Devang Garach
 
Fundamental of Node.JS - Internship Presentation - Week7
Devang Garach
 
Overview of React.JS - Internship Presentation - Week 5
Devang Garach
 
Intro to HTML, CSS & JS - Internship Presentation Week-3
Devang Garach
 
Basics of Linux Commands, Git and Github
Devang Garach
 
M.C.A. Internship Project Presentation - Devang Garach [191823011]
Devang Garach
 

Recently uploaded (20)

PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PPTX
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PDF
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
PPTX
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PREVENTIVE PEDIATRIC. pptx
AneetaSharma15
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Exploring-Forces 5.pdf/8th science curiosity/by sandeep swamy notes/ppt
Sandeep Swamy
 
Skill Development Program For Physiotherapy Students by SRY.pptx
Prof.Dr.Y.SHANTHOSHRAJA MPT Orthopedic., MSc Microbiology
 
vedic maths in python:unleasing ancient wisdom with modern code
mistrymuskan14
 
IMMUNIZATION PROGRAMME pptx
AneetaSharma15
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Landforms and landscapes data surprise preview
jpinnuck
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 

Brief Introduction on JavaScript - Internship Presentation - Week4

  • 1. WEEKLY PRESENTATION DURING TRAINING PROGRAM - Devang Garach [email protected] WEEK-4 Information Technology
  • 2. AGENDA JavaScript Introduction JavaScript Variable Declaration JavaScript Data Types JavaScript Objects JavaScript Classes JavaScript Hoisting JavaScript Promises Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 3. JavaScript Introduction JavaScript is a lightweight interpreted, client side scripting language, high level loosely typed dynamic language. Introduced by Netscape in 1995 To Add JavaScript into webpage, there are two ways Internal and External under <script> tags. JavaScript errors are silently ignored by the browsers, to know errors we can use browser console debugging, to open console in browser press F12 key in keyboard. Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 4. JavaScript Variables Declaration Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION We can declare variables in JavaScript by var keyword. var a = 12 //number 12 var a = 12+”a”//String 12a var check=true //boolean true let b = 12 /number 12 const size=100 //number 100
  • 5. JavaScript Variables Declaration (Difference between let, var ,constant) Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION var let const It is available right from the beginning when the JavaScript was introduced It is a new way to declare variables in JavaScript, starting from ES6 or ECMAScript 2015 const is used to store a value that will not be changed throughout the execution of the script, it is also introduced with ES6 It has a global/ function scope It has block scope It also has block scope Can be updated or re- declared in its scope We can't re-declare them const represent a const value, so it can't be updated or re-declared
  • 6. JavaScript Data Types Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION In JavaScript there are 5 different data types that we can contain values - string - number - boolean - object - function There are 3 types of object - Object, Date , Array and 2 data types that cannot contain values: - null and undefined
  • 7. JavaScript Object JavaScript is designed on a simple object-based paradigm. An object is a collection of properties, and a property is an association between a name (or key) and a value. A property's value can be a function, in which case the property is known as a method. Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION (Source : w3school.com)
  • 8. JavaScript Object (Continue...) To declare objects, The values are written as name:value pairs (name and value separated by a colon). var car = {type:"Fiat", model:"500", color:"white"}; var person = { firstName: "John", lastName : "Doe", id : 5566, fullName : function() { return this.firstName + " " + this.lastName; } }; Also by using New Keyword we can create object ot String, Number, Boolean... object Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 9. JavaScript Class JavaScript Class were introduced in ES6 JavaScript Class Syntax Use the keyword class to create a class. Always add a method named constructor() and methods: class ClassName { constructor() { ... } method_1() { ... } method_2() { ... } method_3() { ... } } Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 10. JavaScript Class (Continue...) class Car { constructor(name, year) { this.name = name; this.year = year; } age(x) { return x - this.year;} } let date = new Date(); let year = date.getFullYear(); let myCar = new Car("Ford",2014); document.getElementById("demo").innerHTML= "My car is " + myCar.age(year) + " years old."; Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 11. JavaScript Hoisting Hoisting is JavaScript's default behavior of moving declarations to the top In JavaScript, a variable can be declared after it has been used. In other words; a variable can be used before it has been declared Not only variables but also function declarations are moved to the top of their scope before code execution JavaScript only hoists declarations, not initializations. Example: x = 5; // Assign 5 to x elem = document.getElementById("demo"); // Find an element elem.innerHTML = x; // Display x in the element var x; // Declare x Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 12. JavaScript Promises As we all know that JavaScript is an asynchronous scripting language. Promises are used to handle asynchronous operations in JavaScript. They are easy to manage when dealing with multiple asynchronous operations where callbacks can create callback hell leading to unmanageable code. Benefits of Promises ● Improves Code Readability ● Better handling of asynchronous operations ● Better flow of control definition in asynchronous logic ● Better Error Handling Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 13. JavaScript Promises (Continue...) A Promise has four states: ● fulfilled: Action related to the promise succeeded ● rejected: Action related to the promise failed ● pending: Promise is still pending i.e not fulfilled or rejected yet ● settled: Promise has fulfilled or rejected A promise can be created using Promise constructor. Syntax: var promise = new Promise(function(resolve, reject){ //do something } ); Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 14. JavaScript Promises (Continue...) Promise Consumers: Promises can be consumed by registering functions using .then and .catch methods. then() is invoked when a promise is either resolved or rejected. Parameters: then() method takes two functions as parameters. Success or Error. Example: var promise = new Promise(function(resolve, reject) { resolve('Geeks For Geeks'); }) promise.then( function(successMessage) { //success handler function is invoked console.log(successMessage); }, function(errorMessage) { console.log(errorMessage); }) Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 15. JavaScript Promises (Continue...) Promises Methods: Promise.all([array]) If the returned promise resolves, it is resolved with an aggregating array of the values from the resolved promises, in the same order as defined in the iterable of multiple promises. If it rejects, it is rejected with the reason from the first promise in the iterable that was rejected. Promise.allSettled() Wait until all promises have settled (each may resolve or reject). Returns a Promise that resolves after all of the given promises have either resolved or rejected, with an array of objects that each describe the outcome of each promise. Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION
  • 16. JavaScript Promises (Continue...) Promises Methods: Promise.any(): Takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfills, returns a single promise that resolves with the value from that promise. Promise.finally() - finally is an instance method like then() , catch() Appends a handler to the promise, and returns a new promise that is resolved when the original promise is resolved. The handler is called when the promise is settled, whether fulfilled or rejected. Information Technology DURING TRAINING PROGRAM - WEEKLY PRESENTATION