TITLE: Largest prime representable in javascript
QUESTION [6 upvotes]: In Javascript, the largest integer that can be represented exactly is Number.MAX_SAFE_INTEGER, with a value of $ 2^{53} - 1$. What is the largest prime value that fits under this value threshold? I cannot find a suitable reference for this value on the internet.

REPLY [6 votes]: I believe the question asks for the largest prime representable in JavaScript, instead of the largest prime less than $2^{53}$, which is trivial to calculate.
From this perspective, I have to point out that the suggested method using Number.MAX_SAFE_INTEGER is not reliable in a strict sense. The information provided in the question regarding Number.MAX_SAFE_INTEGER had been inaccurate.
Actually, instead of being 'the largest integer that can be represented exactly', ECMAScript Language Specification explains that: 

The value of Number.MAX_SAFE_INTEGER is the largest integer n such that n and n + 1 are both exactly representable as a Number value.

This statement only implies the fact that the integer $2^{53}$ alone cannot be exactly represented, and it does not suggest that all integers larger than that value cannot be represented. Therefore, merely from Number.MAX_SAFE_INTEGER we cannot easily decide the upper bound of representable integers.
So, to solve the problem, it is unavoidable that we look into the way how number values are described in JavaScript. According to the Language Specification on the Number Type, aside from special values NaN, Infinity and zero, all finite nonzero number values are described in the form
$$\color{green}s \times \color{green}m \times 2^{\color{green}e}.$$
Where $\color{green}s$ is $+1$ or $-1$, $\color{green}m$, $\color{green}e$ are integers and $0 < \color{green}m < 2^{53}$, $-1074 \le \color{green}e \le 971$.
It is now clear to see that to get the largest prime, we should set $\color{green}s$ to $+1$. $\color{green}e$ cannot be negative, or the $2^{\color{green}e}$ factor would make the value smaller; and $\color{green}e$ cannot be positive, or the value would have a factor of $2$, not a prime; therefore $\color{green}e$ must be $0$. By choosing $\color{green}m$ to be an appropriate value, we are able to get any positive integer smaller than $2^{53}$.
Hence, we can say that the requested prime is $9007199254740881$. (The number can be obtained in JavaScript by simple trial division in a reasonable time. The code is shown here.)