ES6 .Math object | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

ES6 .Math object

What is the working of .Math and .map in JavaScript? Tell in details...

12th Jan 2019, 8:20 PM
Rabia Mithani
Rabia Mithani - avatar
2 Answers
+ 1
Hello!)I think that this methods are similar in ES5 and ES6. Maybe I do not understand your question right) Sorry)
12th Jan 2019, 8:23 PM
bondcoder
bondcoder - avatar
0
The map () method creates a new array with the results of the indicated function call applied to each of its elements. Example: var numbers = [1, 5, 10, 15]; var doubles = numbers.map (function (x) { return x * 2; }); // doubles is now [2, 10, 20, 30] // numbers is still [1, 5, 10, 15] var numbers = [1, 4, 9]; var roots = numbers.map (function (num) { return Math.sqrt (num); }); // roots is now [1, 2, 3] // numbers is still [1, 4, 9] And Math is a built-in object that has properties and methods for constants and mathematical functions.
12th Jul 2020, 11:50 PM
Juancho
Juancho - avatar