在以下代码中,如果我在alertFinished
中的doHomework
上加上括号,为什么在“开始数学作业”之前发出“完成作业”警报?
function doHomework(subject, callback) {
alert(`Starting my ${subject} homework.`);
callback();
}
function alertFinished(){
alert('Finished my homework');
}
doHomework('math', alertFinished())
//With parentheses;