Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Tags more
Archives
Today
Total
관리 메뉴

개발의변화

자바스크립트 2.자료구조와 자료형 본문

카테고리 없음

자바스크립트 2.자료구조와 자료형

refindmySapporo 2021. 9. 27. 19:45
반응형

소수점 구하기

Math.floor

소수점 첫째 자리에서 내림 

Math.ceil

소수점 첫째 자리에서 올림

Math.round

소수점 첫째 자리에서 반올림

Math.trunc

소수부를 무시 

소수점 n 번째까지의 어림 수를 구한 후 이를 문자형으로 반환해주는 메서드인 toFixed를 사용

isNAN 인수를 숫자로 변환한 다음 Nan인지 테스트함

alert (NaN === NaN) false

isFinite("15")

parseInt('100px') = 100

parseFloat('12.5em') = 12.5

Math.random() 0과 1사이의 난수를 반환함

Math.power n을 power번 거듭제곱한 값을 반환함

문자열 접근 let str = 'Hello' ;

alert (str[0])

alert(str.charAt(0))

toUpperCase 대문자 변경, toLowerCase 소문자변경

중요!! 문자열 찾기

str.indexOf(substr,pos)

let str = 'Widget with id' 

alert(str.indexOf('Widget'))

alert= 0

str.includes(substr, pos) 

alert("Widget".includes("id") ); true

alert("Widget".includes("id",3) ) ; false

let str = "stringify" ;

alert ( str.slice(0,5) );

반응형