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

More Related Content

What's hot (20)

Retrieving data using the sql select statement
Retrieving data using the sql select statementRetrieving data using the sql select statement
Retrieving data using the sql select statement
Syed Zaid Irshad
 
Php string function
Php string function Php string function
Php string function
Ravi Bhadauria
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
Amrit Kaur
 
Dom
DomDom
Dom
Rakshita Upadhyay
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
Karmatechnologies Pvt. Ltd.
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Arulmurugan Rajaraman
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
ritika1
 
JavaScript and BOM events
JavaScript and BOM eventsJavaScript and BOM events
JavaScript and BOM events
Jussi Pohjolainen
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
Richard Paul
 
PHP Loops and PHP Forms
PHP  Loops and PHP FormsPHP  Loops and PHP Forms
PHP Loops and PHP Forms
M.Zalmai Rahmani
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
Jquery
JqueryJquery
Jquery
Girish Srivastava
 
Stored procedure in sql server
Stored procedure in sql serverStored procedure in sql server
Stored procedure in sql server
baabtra.com - No. 1 supplier of quality freshers
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
Aneega
 
Frontend 'vs' Backend Getting the Right Mix
Frontend 'vs' Backend   Getting the Right MixFrontend 'vs' Backend   Getting the Right Mix
Frontend 'vs' Backend Getting the Right Mix
Bob Paulin
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
ppd1961
 
Arrays in PHP
Arrays in PHPArrays in PHP
Arrays in PHP
Compare Infobase Limited
 
Database testing
Database testingDatabase testing
Database testing
Hrushikesh Wakhle
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
Nisa Soomro
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
Gil Fink
 

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)

Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
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...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
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free DownloadViral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI FoundationsOracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
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...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
 
Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.Introduction to Internet of things .ppt.
Introduction to Internet of things .ppt.
hok12341073
 
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Scaling GenAI Inference From Prototype to Production: Real-World Lessons in S...
Anish Kumar
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME FlowProviding an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025Developing Schemas with FME and Excel - Peak of Data & AI 2025
Developing Schemas with FME and Excel - Peak of Data & AI 2025
Safe Software
 
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdfcnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
cnc-drilling-dowel-inserting-machine-drillteq-d-510-english.pdf
AmirStern2
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOMEstablish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Establish Visibility and Manage Risk in the Supply Chain with Anchore SBOM
Anchore
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely Demo Showcase: Powering ServiceNow Discovery with Precisely Ironstr...
Precisely
 
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdfBoosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Boosting MySQL with Vector Search -THE VECTOR SEARCH CONFERENCE 2025 .pdf
Alkin Tezuysal
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
PyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent IntegrationPyData - Graph Theory for Multi-Agent Integration
PyData - Graph Theory for Multi-Agent Integration
barqawicloud
 
Domino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use CasesDomino IQ – What to Expect, First Steps and Use Cases
Domino IQ – What to Expect, First Steps and Use Cases
panagenda
 
Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025Mastering AI Workflows with FME - Peak of Data & AI 2025
Mastering AI Workflows with FME - Peak of Data & AI 2025
Safe Software
 
Trends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary MeekerTrends Artificial Intelligence - Mary Meeker
Trends Artificial Intelligence - Mary Meeker
Clive Dickens
 
TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025TimeSeries Machine Learning - PyData London 2025
TimeSeries Machine Learning - PyData London 2025
Suyash Joshi
 

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 ) );