코딩하는 둥둥

Math.abs 메서드 본문

Frontend/JavaScript

Math.abs 메서드

둥둥 2022. 11. 9. 14:07
728x90

Math.abs 메서드

  • 숫자의 절대값을 반환한다.
    • 따라서 결과값은 항상 양수 아니면 0이다.
  • NaN : 값이 숫자가 아닐 경우

        Math.abs(-1) // 1
        Math.abs(1) // 1
        Math.abs(0) // 0
    

References.

https://www.w3schools.com/jsref/jsref_abs.asp

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs

728x90

'Frontend > JavaScript' 카테고리의 다른 글

setInterval  (0) 2022.11.19
Math.floor  (0) 2022.11.19
이벤트(Event)  (0) 2022.11.09
콜백 함수(Callback)  (0) 2022.11.09
Object.entries  (0) 2022.10.28