ในการรับสแควร์รูทของ 2 ให้ใช้คุณสมบัติ JavaScript Math SQRT2 คืนค่ารากที่สองของ 2 ซึ่งมีค่าประมาณ 1.414
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อรับสแควร์รูทของ 2 ใน JavaScript -
<html>
<head>
<title>JavaScript Math SQRT2 Property</title>
</head>
<body>
<script>
var property_value = Math.SQRT2
document.write("Property Value: " + property_value);
</script>
</body>
</html>