○ 자바스크립트 내장 객체(Object)
- 자바스크립트에 내장되어 있는 객체
- object = 멤버변수(변수, property, attribute, field, column) + 멤버함수(함수, function, method) 로 구성
- 객체명.멤버변수
- 객체명.멤버함수()
○ Math객체
- 수학과 관련되어 있는 객체
- 수학에서 자주 사용되는 상수, 함수들 사용 가능
07.JavaScript Math객체
○ Math 객체 - 수학과 관련되어 있는 객체 - 수학에서 자주 사용되는 상수, 함수들 사용 가능 - 사용법 : Math.변수명 | Math.함수() document.write(Math.E); //2.718281828459045 document.write(Math.PI); //3..
binscode.tistory.com
○ Date객체
- 날짜 관련 내장 객체
15. JavaScript Date 객체 (디지털 시계 만들기)
○ Date 객체 - 날짜 관련 내장 객체 var d=new Date(); //시스템의 현재 날짜 정보 가져오기 document.write(d); //Wed May 04 2022 12:00:26 GMT+0900 (한국 표준시) document.write(d.getFullYear()); //현재연..
binscode.tistory.com
○ Array객체
- 배열 객체
12. JavaScript 배열(Array)
○ Array (배열) - 연속성 자료형, 열거형, 컬렉션 - 하나의 변수에 1개 이상의 값을 저장할 수 있는 공간 - element, 요소, 원소 - index, 순서, 색인 (0부터 ..
binscode.tistory.com
○ Number객체
document.write(Number("5")); //숫자5 반환
document.write(Number("8.9")); //숫자8.9 반환
document.write("5"+"8.9"); //"58.9"
document.write(Number("5")+Number("8.9")); //13.9
○ window객체
- 브라우저에 내장된 브라우저 객체 중 최상위 객체
- window.는 생략가능
① alert() : 경고창 띄우기
window.alert(); // 경고창(확인)
alert(); // window.은 생략가능
alert("KOREA");
② confirm() : 질문창 띄우기
window.confirm(); // 경고창(확인, 취소) → 확인을 누르면true, 취소를 누르면 false 반환
confirm(); // window.은 생략가능
confirm("영구히 삭제됩니다\n지울까요?");
③ open() : 새창으로 url 띄우기
④ print() : 인쇄창 띄우기
open("https://www.naver.com"); //naver가 새창으로 뜸
window.print(); //현재 페이지 인쇄창이 뜸
⑤ setInterval()과 setTimeout() : 주어진 시간에 따라 자동으로 함수 호출
- setInterval(함수명, 시간) : 주기적으로 함수 호출
- setTimeout(함수명, 시간) : 한번만 호출
- 시간: millisecond단위로 입력 (1 second = 1000 milliseconds)
- 해제: clearInterval(), clearTimeout()
function hello(){
alert("안녕하세요");
}//hello() end
setInterval(hello, 3000); //3초마다 주기적으로 hello함수 호출
setTimeout(hello, 3000); //3초후에 hello함수 단 1번만 호출
○ screen객체
- 사용자 device의 해상도 확인
document.write(screen.width);
document.write(screen.height);
○ location객체
- 페이지 이동 (HTML에서 anchor태그 역할 <a href""></a>)
- location.href="URL 또는 페이지명";
location.href="http://www.naver.com";
location.reload(); //현재 페이지 새로고침
○ history객체
- 뒤로(이전페이지), 앞으로(다음페이지)
history.back(); //뒤로
history.forward(); //앞으로
history.go(-2); //뒤로 2번
history.go(2); //앞으로 2번
'Frontend > JavaScript' 카테고리의 다른 글
18. JavaScript 연습문제 (이미지스크롤) (0) | 2022.05.11 |
---|---|
17. JavaScript 이벤트(Event) (0) | 2022.05.10 |
15. JavaScript Date 객체 (디지털 시계 만들기) (0) | 2022.05.04 |
14. JavaScript 함수 (Function: 사용자 정의 함수, 변수의 유효범위) (0) | 2022.05.03 |
13. JavaScript 연습문제 모음 (Array) (0) | 2022.05.02 |
댓글