Computer >> 컴퓨터 >  >> 프로그램 작성 >> JavaScript

JavaScript의 Math.abs() 함수

<시간/>

abs() Math 개체의 함수는 숫자를 받아들이고 절대값을 반환합니다.

구문

구문은 다음과 같습니다.

Math.abs(3)

예시

<html>
<head>
   <title>JavaScript Example</title>
</head>
<body>
   <script type="text/javascript">
      var result = Math.abs(3);
      document.write("Absolute value: "+result);
   </script>
</body>
</html>

출력

Absolute value: 3