JavaScript Math.SQRT2 Constant

Definition
Math.SQRT2 is a built-in constant that holds the square root of 2, about 1.4142135623730951. You read it as a property. You do not call it.
Read the value, use it in your math, and check the examples below for common patterns.
Syntax
Read the constant. Start with this line.
| Usage | What it does |
|---|
Math.SQRT2 | Read the square root of 2. |
Built into JavaScript. Read Math.SQRT2 directly from the Math object — no parentheses and no import required.
Library declarations
Parameters
None. Math.SQRT2 is a constant (a fixed value), not a function. Do not add parentheses.
Return Value
| Return Value | Description |
|---|
| Number | About 1.4142135623730951. |
JavaScript Examples
Example 1 — Read the Value of Math.SQRT2
No parentheses are needed.
console.log(Math.SQRT2); // 1.4142135623730951
console.log(Math.SQRT2.toFixed(4)); // 1.4142
console.log((Math.SQRT2 * Math.SQRT2).toFixed(4)); // 2.0000
1.4142135623730951
1.4142
2.0000
How It Works
- Plain property.
Math.SQRT2 is a value, not a function. - Short form.
toFixed(4) keeps 4 decimals. - Square it. Multiplying the number by itself should give
2. - Rounding. The raw result is a hair above
2, so toFixed() makes it clean.
Example 2 — Diagonal of a Square
The diagonal of a square is its side length times the square root of 2.
const side = 10;
const diagonal = side * Math.SQRT2;
console.log(diagonal.toFixed(2)); // 14.14
console.log(Math.sqrt(side * side + side * side).toFixed(2)); // 14.14
How It Works
- Side. A square with side
10. - Shortcut.
10 * Math.SQRT2 is about 14.14. - Pythagoras.
Math.sqrt(10² + 10²) gives the same answer. - Same result. Both print
14.14.
Example 3 — Compare with Math.sqrt(2)
The constant and the function return the same number. It is also the reverse of Math.SQRT1_2.
console.log(Math.sqrt(2)); // 1.4142135623730951
console.log(Math.SQRT2 === Math.sqrt(2)); // true
console.log((Math.SQRT2 * Math.SQRT1_2).toFixed(4)); // 1.0000
1.4142135623730951
true
1.0000
How It Works
- Function.
Math.sqrt(2) calculates the root. - Equal. The constant holds the same number, so
=== gives true. - Times SQRT1_2.
Math.SQRT2 * Math.SQRT1_2 is about 1. - Why use it? It is short, clear and ready to use.
Compatibility
Browser & Runtime Support
Math.SQRT2 is part of the first JavaScript standard (ES1) and is Baseline Widely available in every browser and in Node.js.
✓ Baseline · ES1
Math.SQRT2
A long-standing constant. It works in Chrome, Firefox, Safari, Edge, Internet Explorer and Node.js.
99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full supportMath.SQRT2 Excellent
Bottom line: Use Math.SQRT2 anywhere. It works in all browsers.
Frequently Asked Questions
It is the square root of 2, about 1.4142135623730951.
No. It is a number. Write Math.SQRT2 without parentheses.
Yes. They have the same value.
The constant is rounded, so the answer is 2.0000000000000004. Use toFixed() or Math.round() to clean it up.
It gives the diagonal of a square, and it is common in geometry, graphics and sound code.
All of them. It is part of the first JavaScript standard and works in every browser and in Node.js.
About the author
Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
9 people found this page helpful