반응형
Math.trunc
-
[Javascript] Math,Math.PI, Math.abs, Math.ceil,Math.round,Math.floor,Math.trunc, pow,sqrt, max,min, Math.random웹/JavaScript 2023. 1. 12. 13:56
수학에 관련된 기능을 가진 빌트인 객체 👉 MDN 문서 보기 정적 프로터피와 메서드만 제공 Number 타입만 지원 - BigInt 사용 불가 I. 주요 정적 프로퍼티 PI - 원주율 console.log( Math.PI ); E - 자연로그의 밑 console.log( Math.E ); II. 주요 정적 메서드 1. abs - 절대값(0 이상) 반환 console.log( Math.abs(123), Math.abs(-123), ); // 0 반환 console.log( Math.abs(0), Math.abs(''), Math.abs(null), Math.abs([]), ); // NaN 반환 console.log( Math.abs('abc'), Math.abs(undefined), Math.abs({a..