ฟังก์ชัน sqrt() ของอ็อบเจกต์ Math ยอมรับตัวเลขและส่งกลับค่ารากที่สองของตัวเลขที่ระบุ
ไวยากรณ์
ไวยากรณ์ของมันคือดังต่อไปนี้
Math.sqrt();
ตัวอย่าง
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script type="text/javascript">
var result = Math.sqrt(169);
document.write("Square root value of the given number: "+result);
</script>
</body>
</html> ผลลัพธ์
Square root value of the given number: 13