[go: up one dir, main page]

0% found this document useful (0 votes)
7 views7 pages

Advance Javascript

The document provides an overview of JavaScript Maps, the some() method, and the reduce() method. It explains how to create a Map with key-value pairs and the syntax for using the some() and reduce() methods with arrays. Key points about the reduce() method highlight its versatility and the importance of providing an initial value.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views7 pages

Advance Javascript

The document provides an overview of JavaScript Maps, the some() method, and the reduce() method. It explains how to create a Map with key-value pairs and the syntax for using the some() and reduce() methods with arrays. Key points about the reduce() method highlight its versatility and the importance of providing an initial value.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Presentation

topics
1.map
2.some
3.reduce
-

advance javascript Page 1 of 7


JavaScript Maps

The Map Object


A Map is a special kind of object that stores data
in key-value pairs — but with some powerful
advantages over normal objects.

advance javascript Page 2 of 7


How to Create a Map
You can create a JavaScript Map by:
Passing an Array to new Map()
Create a Map and use Map.set()

Example
const fruits = new Map([
["apples", 500],
["bananas", 300],
["oranges", 200]
]);

advance javascript Page 3 of 7


JavaScript some()
Method
The some() method is used with arrays to check if
at least one element passes the given test
(condition).
It returns true if any element passes, otherwise
false

Syntax
array.some(callbackFunction(element, index, array), thisArg)

advance javascript Page 4 of 7


JavaScript reduce() Method
The reduce() method is used with arrays to
reduce all the elements into a single value (like
sum, product, object, string, etc.).

Syntax
array.reduce(callbackFunction(accumulator, currentValue, index,
array), initialValue)

advance javascript Page 5 of 7


Key Points
of reduce method
reduce() is very powerful – you can do sum, max, min,
group, flatten arrays, build objects, etc.
Always give an initial value to avoid errors on empty
arrays.
Returns a single value (number, object, array, anything
you decide).

advance javascript Page 6 of 7


THANK YOU!

advance javascript Page 7 of 7

You might also like