Math.abs(x)
: 절댓값을 리턴한다.
Math.max
: 파라미터에 여러 수를 넘길 시 가장 큰 값 리턴
Math.min
: 파라미터로 여러 수를 넘기면 가장 작은 수 리턴
Math.abs(-100) //100
Math.max(1,2,3,4,5) //5
Math.min(-1,0,1,2) //-1
Math.pow(x,y)
: x의 y승의 결과값이 리턴
Math.sqrt(x)
: x의 제곱근이 리턴
Math.round(x)
: 반올림값 리턴
Math.floor()
: 버림 값 리턴
Math.ceil()
: 올림 값 리턴
Math.random()
: 0이상 1미만의 값이 랜덤으로 리턴
string.length
: 문자열 길이 리턴
string.charAt(n)
: 인덱스 문자 리턴
const string = 'hello'
string.charAt(2); // index 2번의 l을 리턴.
string.indexOf(searchvalue)
: searchvalue가 string내에 있는 지 검사
string.lastIndexOf(searchvalue)
: searchvalue가 string 내에 있는 지 검사 후 가장 뒤에 위치한 문자열의 인덱스 리턴string.toUpperCase()
: 대문자로 변환 후 리턴
string.toLowerCase()
: 소문자로 변환 후 리턴
string.substring(indexstart,indexend)
: 시작 인덱스부터 끝 인덱스 바로앞까지의 문자열을 잘라서 리턴
string.trim()
array.length
: 배열 길이 리턴
array.indexOf(item)
array.push()
: 추가
array.pop()
: 빼기 - 마지막 요소가 리턴
array.join()
array.join('??')
- 배열 아이템 사이에 ??가 들어가게 됨.// 현재 날짜로 설정
const date = new Date()
// 원하는 날짜로 설정
const date2 = new Date('July 1, 1999 05:25:40');
const date3 = new Date('12/12/2020');
var date = new Date('June 11, 1988 05:25:30');
console.log(date.getFullYear());
console.log(date.getMonth()); // 0부터 시작, 2는 3월을 의미
console.log(date.getDate());
console.log(date.getDay()); //요일 리턴 0이 일요일
console.log(date.getHours());
console.log(date.getMinutes());
console.log(date.getSeconds());
console.log(date.getMilliseconds());
console.log(date.toString());
console.log(date.toLocaleString());
console.log(date.toLocaleDateString());
console.log(date.toLocaleTimeString());
// 초, 분, 시, 일 단위
console.log(date.getTime() + 'ms');
console.log(date.getTime()/1000 + '초');
console.log(date.getTime()/1000/60 + '분');
console.log(date.getTime()/1000/60/60 + '시간');