Home >Web Front-end >JS Tutorial >Discussion on the problem of parentheses in JS method calling_Basic knowledge

Discussion on the problem of parentheses in JS method calling_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:02:451391browse

For the mobile html page,

wrote a function.

Copy the code The code is as follows:

function showAlert(msg,fn){
showDialog("alert", msg,"warm reminder",260);
if(isNull(fn) == false){
$( "#SD_confirm").unbind("click");
$("#SD_confirm").bind("click",fn);
}
}

function exist( ){

alert("aaa");

}

fn is a function, when calling it I wrote
Copy code The code is as follows:

showAlert(json.msg,exist());

As a result, when I reached this line of code, before I reached the showDialog method, I went to exist and aaa popped up. What happened? I later found out that I had written it wrong.

should be written as
Copy code The code is as follows:

showAlert(json.msg,exist);

In this way, the dialog prompt will pop up first, and then click OK to pop up aaa.

Damn it. It turns out that there was a mistake in the brackets. Sigh!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn