I want to sort an array of numerical values and I find a code likes :
<!DOCTYPE html>
<html>
<body>
<p>Click the button to sort the array in ascending order.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
var points = [40, 100, 1, 5, 25, 10];
document.getElementById("demo").innerHTML = points;
function myFunction() {
points.sort(function(a, b){return a-b});
document.getElementById("demo").innerHTML = points;
}
</script>
</body>
</html>
Output:
1,5,10,25,40,100
The code runs properly but I can't understand how the statement
points.sort(function(a, b){return a-b});
is working and what is a and b?