"confirm" 在 "if" 中。如果 "confirm" 仅位于 "if" 内,它如何启动?

"confirm" in "if". How can "confirm" starts if it's located only inside "if"?

这是代码。您能解释一下 "confirm" 在这里是如何工作的吗?它只是说:“如果有 "confirm" 但实际上没有命令 "confirm"。

function ask(question, yes, no) {
    if (confirm(question)) {
        yes()
    }
    else {
        no();
    }
  }

function showOk() {
  alert( "You are agree." );
}

function showCancel() {
  alert( "You cancelled." );
}

ask("Are you agree?", showOk, showCancel);

confirm is build-in js function (like lots of other functions) 即returns true/false.

if (confirm()) - confirm 将首先执行,并且只有 if 才会比较此函数响应是 true 还是 false