window - 전역 객체로 어디에서든 접근 가능하다.생략 가능하다.
alert("It will be deleted");
if (confirm("Do you want to delete it?")){
console.log("Delete Complete");
}
let name = prompt("Input your name");
if (name == null){
console.log("Pressed cancel button");
}
else if (name == ""){
console.log("Input nothing");
}
else if (name != ""){
console.log(name);
}
alert - 팝업 창 띄우기
confirm - yes or no를 선택할 수 있는 팝업 창 띄우기
promt - 사용자에게서 값을 입력받을 수 있는 팝업 창 띄우기, 취소를 누르면 null, 아무것도 입력하지 않으면 공백 처리
window.print();
open - 새 탭에서 해당 링크에 접속
print - 인쇄 창
setTimeout(function(){
console.log("Print it after 3 seconds");
}, 3000);
let limit = 0;
let repeat = setInterval(function(){
console.log("Print it every 3 seconds : " + limit);
if (limit == 5){
clearInterval(repeat);
console.log("End");
}
limit++;
}, 3000);
setTimeout - 몇 초 후에 해당 함수가 실행된다. 1000 = 1초
setInterval - 몇 초 마다 해당 함수가 실행된다. 1000 = 1초
clearInterval - setInterval을 끝내기 위해 사용한다.
'프로그래밍 > Java Script' 카테고리의 다른 글
Java Script - this (0) | 2022.12.11 |
---|---|
Java Script - 크롬 개발자 도구 Chrome (0) | 2022.12.09 |
Java Script - Json (0) | 2022.12.08 |
Java Script - 수학 메소드 Math Method (0) | 2022.12.08 |
Java Script - 날짜 메소드 Date Method (0) | 2022.12.06 |