Math.abs() 함수

Sung.K·2021년 8월 2일

Math.abs() 함수

Math.abs() 함수는 절대값을 반환해주는 함수이다. int, float, long, double등 입력이 가능하다.

Math.abs('-3'); 3
Math.abs(-4); 4
Math.abs(null); 0
Math.abs(''); 0
Math.abs([]); 0
Math.abs([3]); 3
Math.abs([2,3]); NaN(Not-A-Number(숫자가 아님)
Math.abs({}); NaN
Math.abs('string');NaN
Math.abs(); NaN

profile
Towards the goal 👀

0개의 댓글