Home > Web Front-end > JS Tutorial > body text

Do JavaScript functions have to be defined?

醉折花枝作酒筹
Release: 2023-01-07 11:44:40
Original
1933 people have browsed it

Javascript functions do not need to be defined, just use parameters directly, but the types must correspond; JavaScript does not strictly control parameter types, for example, "function myFunction(a,b){}" is also acceptable.

Do JavaScript functions have to be defined?

The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.

No need to define, just use the parameters directly, but the types must correspond.

javascript does not have strict control over parameter types

It is different from many other languages

For example:

function ajax(url,fnSucc,fnFaile)
{
if (window.XMLHttpRequest)
{
var oAjax = new XMLHttpRequest();
}
else
{
var oAjax = new ActiveXObject("Microsoft.XMLHTTP");
}
oAjax.open('GET', url, true);
oAjax.send();
oAjax.onreadystatechange = function () {
if (oAjax.readyState == 4)
{
if (oAjax.status == 200)
{
fnSucc(oAjax.responseText);
}
else
{
if (fnFaile)
{
fnFaile(oAjax.status);
}
}
}
};
}
Copy after login

[Recommended learning:javascript advanced tutorial

The above is the detailed content of Do JavaScript functions have to be defined?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template