Math Flashcards

1
Q

Math.max()

A

Syntax: Math.max(val1, val2, …valN);

Because max() is a static method of Math, you always use it as Math.max(), rather than as a method of a Math object you created (Math is not a constructor).

If no arguments are given, the result is -Infinity.

If at least one of arguments cannot be converted to a number, the result is NaN.

Useful function for getting Math.max() of arrays:

function getMaxOfArray(numArray) {
  return Math.max.apply(null, numArray);
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Number.prototype.toFixed([decimalplaces])

A

Rounds a number to the number of decimal places specified by the argument. If omitted, treated as zero.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly