개발 이야기/개발 도서

제로초 자바스크립트 입문 <window 객체>

sonoa 2024. 3. 14. 16:50
반응형

대화상자 사용하기 

alert('여러 줄에 걸쳐\n표시합니다.');
prompt('사용자에게 표시할 메세지')
prompt('몇 명이 참가하나요?');
confirm('사용자에게 표시할 메세지')
confirm('확인이나 취소를 눌러 보세요.');

Math 객체 

  • 올림 Math.ceil( )
  • 반올림 Math.round( )
  • 내림 Math.floor( )
  • 최댓값 Math.max( )
  • 최솟값 Math.min( )
  • 제곱급 Math.sqrt( )
  • 무작위 숫자 Math.random( )

Date 생성자 함수 

  • const <날짜 객체> = new Date(연, 월, 일, 시, 분, 초, 밀리초);
  • const <날짜 객체> = new Date(타임스탬프);
Date.now();
< (타임스탬프)
new Date();
< (현재 시간)

new Date(2024, 1, 2);
< Fri Feb 2 2024 00:00:00 GMT+0900 (대한민국 표준시)
new Date(2024, 1, 2, 18, 30, 5);
< Fri Feb 2 2024 18:30:05 GMT+0900 (대한민국 표준시)

new Date(2024, 2, 3) - new Date(2024, 1, 21)
< 950400000

const date = new Date(2024, 1, 2);
date.setDate(10);
< 1707490800000
date.getDate();
< 10

const date = new Date(2024, 0, 1);
date.setDate(date.getDate() - 1);
< 1703948400000
date.getFullYear();
< 2023
date.getMonth();
< 11 (12월)
date.getDate();
< 31
반응형