0
ES6 .Math object
What is the working of .Math and .map in JavaScript? Tell in details...
2 Respostas
+ 1
Hello!)I think that this methods are similar in ES5 and ES6. Maybe I do not understand your question right) Sorry)
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.