How does JavaScript Map Function work....
Here is an example
var numbers = [4, 9, 16, 25];
function myFunction() {
x = document.getElementById("demo")
x.innerHTML = numbers.map(Math.sqrt);
}
If I execute the above function as part of my Javascript it print
2,3,4,5
So what happened using map function I applied the Math.sqrt to every element of my numbers array.
Here is an example
var numbers = [4, 9, 16, 25];
function myFunction() {
x = document.getElementById("demo")
x.innerHTML = numbers.map(Math.sqrt);
}
If I execute the above function as part of my Javascript it print
2,3,4,5
So what happened using map function I applied the Math.sqrt to every element of my numbers array.