SlideShare a Scribd company logo
Map, WeakMap | ES6
JAGADEESH PATTA ( PJ )
Agenda
 Introduction
 Object vs Map
 Map Syntax
 Method on Map
 Live Examples
 WeakMap
 WeakMap syntax
 Methods on WeakMap
 Live Example
Introduction
 The map object holds the data as key-value pair.
 The value may be any object or primitive data values.
 A map object iterates its elements in insertion order.
 Using for…of loop we can get key, values as an array for each iteration.
 We can give NaN as key in map.
Object vs Map
 Object allows keys only either strings or symbols. But map can allow any
type of data like primitives, functions, objects, etc.
 We can get values from object by using object[“key”] or object.key. But to
get values from map by using map.get(“key”) method.
 Data in the object can be any order. But in map the order of the keys based
on insertion of the data to map.
Syntax
Syntax
let map = new Map();
Example
let employeeMap = new Map();
Methods on Map
Clear( )
Delete( key )
Entries( )
Get( key )
Has( key )
Keys( )
Values( )
Set( key, val )
Insert Data into Map
let employeeMap = new Map( );
employeeMap.set(“empId”, 46);
employeeMap.set(“name”, “Jagadeesh”);
employeeMap.set(“designation”, “SSE”);
Get Data from Map
 Using forEach
 Using for…of
 Manual approach
Get Data from Map(cont…)
forEach
var map = new Map( );
map.forEach( function( key, val ){
console.log( key + “ “ + val );
});
Get Data from Map(cont…)
For…of
var map = new Map( );
for( let [ key, val ] of map ) {
console.log( key + “ “ + val );
}
Get Data from Map(cont…)
For…of ( cont…)
var map = new Map( );
for( let key of map.keys( ) ) {
console.log( key );
}
Get Data from Map(cont…)
For…of ( cont…)
var map = new Map( );
for( let val of map.values( ) ) {
console.log( val );
}
Get Data from Map(cont…)
For…of ( Cont…)
var map = new Map( );
for( let [ key, val ] of map.entries( ) ) {
console.log( key + “ “ + val );
}
Get Data from Map(cont…)
Manual
var map = new Map( );
console.log( map.get( key ) ); OR
var keys = map.keys( );
for ( let index = 0; index < keys.length; index++ ){
console.log( map.get( keys[ index ] ) );
}
WeakMap
 The weakmap object holds the data as key-value pair.
 In weakmap the keys are weakly referenced.
 The keys must be objects, and the values can be any values.
 We cannot get length of weakmap.
 Weakmap not allowed to get keys by keys() method.
Syntax
Syntax
let map = new WeakMap();
Example
let employeeMap = new WeakMap();
Methods on WeakMap
Delete( key )
Get( key )
Has( key )
Set( key, val )
WeakMap Example
let employeeMap = new WeakMap( );
var idObj = new Object( );
employeeMap.set( idObj, 46);
console.log( employeeMap.get( idObj ) );
Any Q ?
Thank You
Ad

More Related Content

What's hot (20)

Photoshop
PhotoshopPhotoshop
Photoshop
argusacademy
 
Graphical representation of Stack
Graphical representation of StackGraphical representation of Stack
Graphical representation of Stack
Sanjay Kumar Chakravarti
 
Spray Json and MongoDB Queries: Insights and Simple Tricks.
Spray Json and MongoDB Queries: Insights and Simple Tricks.Spray Json and MongoDB Queries: Insights and Simple Tricks.
Spray Json and MongoDB Queries: Insights and Simple Tricks.
Andrii Lashchenko
 
History of-web-design
History of-web-designHistory of-web-design
History of-web-design
Web Designers Nepal
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
www.netgains.org
 
Advanced Matchmaking with Multiplay – Unite Copenhagen 2019
Advanced Matchmaking with Multiplay – Unite Copenhagen 2019Advanced Matchmaking with Multiplay – Unite Copenhagen 2019
Advanced Matchmaking with Multiplay – Unite Copenhagen 2019
Unity Technologies
 
Scratch Lesson 2 – Paint Editor
Scratch Lesson 2 – Paint EditorScratch Lesson 2 – Paint Editor
Scratch Lesson 2 – Paint Editor
David Oromaner
 
Scratch Animation
Scratch AnimationScratch Animation
Scratch Animation
Anjan Mahanta
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 
Beginners' Guide to Powerpoint
Beginners' Guide to PowerpointBeginners' Guide to Powerpoint
Beginners' Guide to Powerpoint
Laura Hampton
 
OWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
OWASP ESAPI and Microsoft Web Libraries in Cross-Site ScriptingOWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
OWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
Denim Group
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Philip Schwarz
 
Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Sequence and Traverse - Part 1
Sequence and Traverse - Part 1
Philip Schwarz
 
Css properties
Css propertiesCss properties
Css properties
Dr. SURESH KUMAR Krishnamoorthy
 
Scratch Lesson 1 – Basics
Scratch Lesson 1 – BasicsScratch Lesson 1 – Basics
Scratch Lesson 1 – Basics
David Oromaner
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
David Lindkvist
 
laravel resume10 trés résume avec les coses importatnt.pdf
laravel resume10 trés résume avec les coses importatnt.pdflaravel resume10 trés résume avec les coses importatnt.pdf
laravel resume10 trés résume avec les coses importatnt.pdf
rachidtamesna12
 
HTML5 Topic 1
HTML5 Topic 1HTML5 Topic 1
HTML5 Topic 1
Juvywen
 
Java script arrays
Java script arraysJava script arrays
Java script arrays
Frayosh Wadia
 
HTML
HTMLHTML
HTML
Gouthaman V
 
Spray Json and MongoDB Queries: Insights and Simple Tricks.
Spray Json and MongoDB Queries: Insights and Simple Tricks.Spray Json and MongoDB Queries: Insights and Simple Tricks.
Spray Json and MongoDB Queries: Insights and Simple Tricks.
Andrii Lashchenko
 
Advanced Matchmaking with Multiplay – Unite Copenhagen 2019
Advanced Matchmaking with Multiplay – Unite Copenhagen 2019Advanced Matchmaking with Multiplay – Unite Copenhagen 2019
Advanced Matchmaking with Multiplay – Unite Copenhagen 2019
Unity Technologies
 
Scratch Lesson 2 – Paint Editor
Scratch Lesson 2 – Paint EditorScratch Lesson 2 – Paint Editor
Scratch Lesson 2 – Paint Editor
David Oromaner
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
Ankit Kumar
 
Beginners' Guide to Powerpoint
Beginners' Guide to PowerpointBeginners' Guide to Powerpoint
Beginners' Guide to Powerpoint
Laura Hampton
 
OWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
OWASP ESAPI and Microsoft Web Libraries in Cross-Site ScriptingOWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
OWASP ESAPI and Microsoft Web Libraries in Cross-Site Scripting
Denim Group
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Philip Schwarz
 
Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Sequence and Traverse - Part 1
Sequence and Traverse - Part 1
Philip Schwarz
 
Scratch Lesson 1 – Basics
Scratch Lesson 1 – BasicsScratch Lesson 1 – Basics
Scratch Lesson 1 – Basics
David Oromaner
 
laravel resume10 trés résume avec les coses importatnt.pdf
laravel resume10 trés résume avec les coses importatnt.pdflaravel resume10 trés résume avec les coses importatnt.pdf
laravel resume10 trés résume avec les coses importatnt.pdf
rachidtamesna12
 
HTML5 Topic 1
HTML5 Topic 1HTML5 Topic 1
HTML5 Topic 1
Juvywen
 

Similar to 12. Map | WeakMap | ES6 | JavaScript | Typescript (20)

Collection and framework
Collection and frameworkCollection and framework
Collection and framework
SARAVANAN GOPALAKRISHNAN
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
Eleanor McHugh
 
An important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdfAn important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdf
ARORACOCKERY2111
 
Use C++ for all 1 bool mapContainsKeysarrayltintgt nu.pdf
Use C++ for all  1 bool mapContainsKeysarrayltintgt nu.pdfUse C++ for all  1 bool mapContainsKeysarrayltintgt nu.pdf
Use C++ for all 1 bool mapContainsKeysarrayltintgt nu.pdf
admin447081
 
Data Types and Processing in ES6
Data Types and Processing in ES6Data Types and Processing in ES6
Data Types and Processing in ES6
m0bz
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
purrr.pdf
purrr.pdfpurrr.pdf
purrr.pdf
Mateus S. Xavier
 
Internal workshop es6_2015
Internal workshop es6_2015Internal workshop es6_2015
Internal workshop es6_2015
Miguel Ruiz Rodriguez
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?
Andrey Akinshin
 
Data Structures in javaScript 2015
Data Structures in javaScript 2015Data Structures in javaScript 2015
Data Structures in javaScript 2015
Nir Kaufman
 
6. Generics. Collections. Streams
6. Generics. Collections. Streams6. Generics. Collections. Streams
6. Generics. Collections. Streams
DEVTYPE
 
Scala Higher Order Functions
Scala Higher Order FunctionsScala Higher Order Functions
Scala Higher Order Functions
Raúl Raja Martínez
 
Creating an Uber Clone - Part XVIII - Transcript.pdf
Creating an Uber Clone - Part XVIII - Transcript.pdfCreating an Uber Clone - Part XVIII - Transcript.pdf
Creating an Uber Clone - Part XVIII - Transcript.pdf
ShaiAlmog1
 
Modular Module Systems
Modular Module SystemsModular Module Systems
Modular Module Systems
league
 
Array
ArrayArray
Array
Radha Rani
 
ISCP internal.pdf
ISCP internal.pdfISCP internal.pdf
ISCP internal.pdf
GANDHAMKUMAR2
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
Eleanor McHugh
 
I want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdfI want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdf
bermanbeancolungak45
 
Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdf
apexelectronices01
 
Lecture notesmap
Lecture notesmapLecture notesmap
Lecture notesmap
Vasanti Dutta
 
Implementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 reduxImplementing virtual machines in go & c 2018 redux
Implementing virtual machines in go & c 2018 redux
Eleanor McHugh
 
An important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdfAn important part of electrical engineering is PCB design. One impor.pdf
An important part of electrical engineering is PCB design. One impor.pdf
ARORACOCKERY2111
 
Use C++ for all 1 bool mapContainsKeysarrayltintgt nu.pdf
Use C++ for all  1 bool mapContainsKeysarrayltintgt nu.pdfUse C++ for all  1 bool mapContainsKeysarrayltintgt nu.pdf
Use C++ for all 1 bool mapContainsKeysarrayltintgt nu.pdf
admin447081
 
Data Types and Processing in ES6
Data Types and Processing in ES6Data Types and Processing in ES6
Data Types and Processing in ES6
m0bz
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?
Andrey Akinshin
 
Data Structures in javaScript 2015
Data Structures in javaScript 2015Data Structures in javaScript 2015
Data Structures in javaScript 2015
Nir Kaufman
 
6. Generics. Collections. Streams
6. Generics. Collections. Streams6. Generics. Collections. Streams
6. Generics. Collections. Streams
DEVTYPE
 
Creating an Uber Clone - Part XVIII - Transcript.pdf
Creating an Uber Clone - Part XVIII - Transcript.pdfCreating an Uber Clone - Part XVIII - Transcript.pdf
Creating an Uber Clone - Part XVIII - Transcript.pdf
ShaiAlmog1
 
Modular Module Systems
Modular Module SystemsModular Module Systems
Modular Module Systems
league
 
Implementing Software Machines in C and Go
Implementing Software Machines in C and GoImplementing Software Machines in C and Go
Implementing Software Machines in C and Go
Eleanor McHugh
 
I want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdfI want help in the following C++ programming task. Please do coding .pdf
I want help in the following C++ programming task. Please do coding .pdf
bermanbeancolungak45
 
Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdf
apexelectronices01
 
Ad

More from pcnmtutorials (18)

11. Iterators | ES6 | JavaScript | TypeScript
11. Iterators | ES6 | JavaScript | TypeScript11. Iterators | ES6 | JavaScript | TypeScript
11. Iterators | ES6 | JavaScript | TypeScript
pcnmtutorials
 
10. symbols | ES6 | JavaScript | TypeScript
10. symbols | ES6 | JavaScript | TypeScript10. symbols | ES6 | JavaScript | TypeScript
10. symbols | ES6 | JavaScript | TypeScript
pcnmtutorials
 
9. ES6 | Let And Const | TypeScript | JavaScript
9. ES6 | Let And Const | TypeScript | JavaScript9. ES6 | Let And Const | TypeScript | JavaScript
9. ES6 | Let And Const | TypeScript | JavaScript
pcnmtutorials
 
8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript
pcnmtutorials
 
7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript
pcnmtutorials
 
6. Default parameters | ES6 | JavaScript
6. Default parameters | ES6 | JavaScript6. Default parameters | ES6 | JavaScript
6. Default parameters | ES6 | JavaScript
pcnmtutorials
 
5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment 5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment
pcnmtutorials
 
4. Template strings | ES6
4. Template strings | ES64. Template strings | ES6
4. Template strings | ES6
pcnmtutorials
 
3. Object literals | ES6 | JSON
3. Object literals | ES6 | JSON3. 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 | JavaScript2. 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 | ES61. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES6
pcnmtutorials
 
Decorators | TypeScript | Angular2 Decorators
Decorators | TypeScript | Angular2 DecoratorsDecorators | TypeScript | Angular2 Decorators
Decorators | TypeScript | Angular2 Decorators
pcnmtutorials
 
Web workers | JavaScript | HTML API
Web workers | JavaScript | HTML APIWeb workers | JavaScript | HTML API
Web workers | JavaScript | HTML API
pcnmtutorials
 
Declaration merging | Typescript
Declaration merging | TypescriptDeclaration merging | Typescript
Declaration merging | Typescript
pcnmtutorials
 
Module resolution | Typescript
Module resolution | TypescriptModule resolution | Typescript
Module resolution | Typescript
pcnmtutorials
 
Material design in android L developer Preview
Material design in android L developer PreviewMaterial 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 structuredata structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 
1.introduction to data_structures
1.introduction to data_structures1.introduction to data_structures
1.introduction to data_structures
pcnmtutorials
 
11. Iterators | ES6 | JavaScript | TypeScript
11. Iterators | ES6 | JavaScript | TypeScript11. Iterators | ES6 | JavaScript | TypeScript
11. Iterators | ES6 | JavaScript | TypeScript
pcnmtutorials
 
10. symbols | ES6 | JavaScript | TypeScript
10. symbols | ES6 | JavaScript | TypeScript10. symbols | ES6 | JavaScript | TypeScript
10. symbols | ES6 | JavaScript | TypeScript
pcnmtutorials
 
9. ES6 | Let And Const | TypeScript | JavaScript
9. ES6 | Let And Const | TypeScript | JavaScript9. ES6 | Let And Const | TypeScript | JavaScript
9. ES6 | Let And Const | TypeScript | JavaScript
pcnmtutorials
 
8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript
pcnmtutorials
 
7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript
pcnmtutorials
 
6. Default parameters | ES6 | JavaScript
6. Default parameters | ES6 | JavaScript6. Default parameters | ES6 | JavaScript
6. Default parameters | ES6 | JavaScript
pcnmtutorials
 
5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment 5. Destructuring | ES6 | Assignment
5. Destructuring | ES6 | Assignment
pcnmtutorials
 
4. Template strings | ES6
4. Template strings | ES64. Template strings | ES6
4. Template strings | ES6
pcnmtutorials
 
3. Object literals | ES6 | JSON
3. Object literals | ES6 | JSON3. 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 | JavaScript2. 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 | ES61. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES6
pcnmtutorials
 
Decorators | TypeScript | Angular2 Decorators
Decorators | TypeScript | Angular2 DecoratorsDecorators | TypeScript | Angular2 Decorators
Decorators | TypeScript | Angular2 Decorators
pcnmtutorials
 
Web workers | JavaScript | HTML API
Web workers | JavaScript | HTML APIWeb workers | JavaScript | HTML API
Web workers | JavaScript | HTML API
pcnmtutorials
 
Declaration merging | Typescript
Declaration merging | TypescriptDeclaration merging | Typescript
Declaration merging | Typescript
pcnmtutorials
 
Module resolution | Typescript
Module resolution | TypescriptModule resolution | Typescript
Module resolution | Typescript
pcnmtutorials
 
Material design in android L developer Preview
Material design in android L developer PreviewMaterial 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 structuredata structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 
1.introduction to data_structures
1.introduction to data_structures1.introduction to data_structures
1.introduction to data_structures
pcnmtutorials
 
Ad

Recently uploaded (20)

Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxDevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptx
Justin Reock
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Quantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur MorganQuantum Computing Quick Research Guide by Arthur Morgan
Quantum Computing Quick Research Guide by Arthur Morgan
Arthur Morgan
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
How analogue intelligence complements AI
How analogue intelligence complements AIHow analogue intelligence complements AI
How analogue intelligence complements AI
Paul Rowe
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Build Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For DevsBuild Your Own Copilot & Agents For Devs
Build Your Own Copilot & Agents For Devs
Brian McKeiver
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-UmgebungenHCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungen
panagenda
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 

12. Map | WeakMap | ES6 | JavaScript | Typescript

  • 1. Map, WeakMap | ES6 JAGADEESH PATTA ( PJ )
  • 2. Agenda  Introduction  Object vs Map  Map Syntax  Method on Map  Live Examples  WeakMap  WeakMap syntax  Methods on WeakMap  Live Example
  • 3. Introduction  The map object holds the data as key-value pair.  The value may be any object or primitive data values.  A map object iterates its elements in insertion order.  Using for…of loop we can get key, values as an array for each iteration.  We can give NaN as key in map.
  • 4. Object vs Map  Object allows keys only either strings or symbols. But map can allow any type of data like primitives, functions, objects, etc.  We can get values from object by using object[“key”] or object.key. But to get values from map by using map.get(“key”) method.  Data in the object can be any order. But in map the order of the keys based on insertion of the data to map.
  • 5. Syntax Syntax let map = new Map(); Example let employeeMap = new Map();
  • 6. Methods on Map Clear( ) Delete( key ) Entries( ) Get( key ) Has( key ) Keys( ) Values( ) Set( key, val )
  • 7. Insert Data into Map let employeeMap = new Map( ); employeeMap.set(“empId”, 46); employeeMap.set(“name”, “Jagadeesh”); employeeMap.set(“designation”, “SSE”);
  • 8. Get Data from Map  Using forEach  Using for…of  Manual approach
  • 9. Get Data from Map(cont…) forEach var map = new Map( ); map.forEach( function( key, val ){ console.log( key + “ “ + val ); });
  • 10. Get Data from Map(cont…) For…of var map = new Map( ); for( let [ key, val ] of map ) { console.log( key + “ “ + val ); }
  • 11. Get Data from Map(cont…) For…of ( cont…) var map = new Map( ); for( let key of map.keys( ) ) { console.log( key ); }
  • 12. Get Data from Map(cont…) For…of ( cont…) var map = new Map( ); for( let val of map.values( ) ) { console.log( val ); }
  • 13. Get Data from Map(cont…) For…of ( Cont…) var map = new Map( ); for( let [ key, val ] of map.entries( ) ) { console.log( key + “ “ + val ); }
  • 14. Get Data from Map(cont…) Manual var map = new Map( ); console.log( map.get( key ) ); OR var keys = map.keys( ); for ( let index = 0; index < keys.length; index++ ){ console.log( map.get( keys[ index ] ) ); }
  • 15. WeakMap  The weakmap object holds the data as key-value pair.  In weakmap the keys are weakly referenced.  The keys must be objects, and the values can be any values.  We cannot get length of weakmap.  Weakmap not allowed to get keys by keys() method.
  • 16. Syntax Syntax let map = new WeakMap(); Example let employeeMap = new WeakMap();
  • 17. Methods on WeakMap Delete( key ) Get( key ) Has( key ) Set( key, val )
  • 18. WeakMap Example let employeeMap = new WeakMap( ); var idObj = new Object( ); employeeMap.set( idObj, 46); console.log( employeeMap.get( idObj ) );