JavaScript Math.SQRT2 Constant

Beginner
5 min read
Updated: Nov 2026
3 examples
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.

JavaScript
Math.SQRT2
UsageWhat it does
Math.SQRT2Read the square root of 2.

Built into JavaScript. Read Math.SQRT2 directly from the Math object — no parentheses and no import required.

Library declarations
JavaScript
Math.SQRT2

Parameters

None. Math.SQRT2 is a constant (a fixed value), not a function. Do not add parentheses.

Return Value

Return ValueDescription
NumberAbout 1.4142135623730951.

JavaScript Examples

Example 1 — Read the Value of Math.SQRT2

No parentheses are needed.

JavaScript
console.log(Math.SQRT2); // 1.4142135623730951
console.log(Math.SQRT2.toFixed(4)); // 1.4142
console.log((Math.SQRT2 * Math.SQRT2).toFixed(4)); // 2.0000
Try It Yourself

How It Works

  1. Plain property. Math.SQRT2 is a value, not a function.
  2. Short form. toFixed(4) keeps 4 decimals.
  3. Square it. Multiplying the number by itself should give 2.
  4. 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.

JavaScript
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
Try It Yourself

How It Works

  1. Side. A square with side 10.
  2. Shortcut. 10 * Math.SQRT2 is about 14.14.
  3. Pythagoras. Math.sqrt(10² + 10²) gives the same answer.
  4. 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.

JavaScript
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
Try It Yourself

How It Works

  1. Function. Math.sqrt(2) calculates the root.
  2. Equal. The constant holds the same number, so === gives true.
  3. Times SQRT1_2. Math.SQRT2 * Math.SQRT1_2 is about 1.
  4. Why use it? It is short, clear and ready to use.

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 support
Math.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.

Back to Math Methods

Browse every Math method and constant from the index.

Math Methods index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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