function sayHi() {
alert( "Hello" );
}
function sayHi() {
alert( "Hello" );
}
alert( sayHi );
함수 선언문 보다는 표현식이 더 빈도가 높다. 이유는 바로 호이스팅 때문
sayHi('hi) // 호이스팅 때문에 sayHi()로 어디서든지 실행이 가능하다.
function sayHi(){
alert("hello)
}
function ask(question, yes, no) {
if (confirm(question)) yes()
else no();
}
function showOk() {
alert( "동의하셨습니다." );
}
function showCancel() {
alert( "취소 버튼을 누르셨습니다." );
}
// 사용법: 함수 showOk와 showCancel가 ask 함수의 인수로 전달됨
ask("동의하십니까?", showOk, showCancel);
// 1.showOk와 showCancel은 함수이다.
// 2. ask라는 함수안에 매개변수로 들어갔다. 즉 콜백함수이다.