带括号的回调函数-Javascript

时间:2019-04-04 17:21:30

标签: javascript

在以下代码中,如果我在alertFinished中的doHomework上加上括号,为什么在“开始数学作业”之前发出“完成作业”警报?

function doHomework(subject, callback) {
  alert(`Starting my ${subject} homework.`);
  callback();
}

function alertFinished(){
  alert('Finished my homework');
}

doHomework('math', alertFinished())
//With parentheses;

0 个答案:

没有答案