The function is an object and the function name is a pointer.
function sayHi(sName, sMessage) { alert("Hello " + sName + sMessage);}
You can also define it as follows:
var sayHi = new Function("sName", "sMessage", "alert(\"Hello \" + sName + sMessage);");
There is no difference between the two types:
1,Javascript is an object-oriented programming language (OOP ). The OOP language enables us to customize object and variable types. Document. Write (txt.length), Document. Write (Str.toUpperCase())
The JS string is the same as the string in our Java and has almost the same functional methods.
2. A JavaScript date object instance can display a dynamic clock, compare the date size directly, and set a specific date for the object.
3. JavaScript (array) defines the array with: New array (), array with for (X in shuzus) [output with no comma], directly output the array with a comma. Arrays can be awakened and merged using the Concat () method,
| Join () |
Put all elements of the array into a string. The elements are separated by the specified delimiter. |
Read Manual
Two Value assignment methods and two output methods. You can use sort to sort text and numbers directly.
4. Unique type boolean type of JS. var myboolean = new Boolean () if the logical object has no initial value or its value is 0,-0, null, "", false, undefined, Or Nan, the object value is false. Otherwise, the value is true (even when the independent variable is string "false )!
5. js arithmetic objects. The methods in the math method can be rounded to and related mathematical operations.
6. Javascript Regexp (Regular Expression) object. A simple mode can be a single character. More complex modes include more characters and can be used for parsing, format check, replacement, and so on.
The Regexp object has three methods: Test (), exec (), and compile ().
7. Javascript variable: In the function, age = XX indicates that it is a global variable. The function is an object rather than a data type.
VaR age; only declare that the variable is not initialized. The typeof variable is of the undefined type, but the variable is used if it is not declared, which is wrong. That is, there are no Defined variables. This is different.
Function Name parameters are only convenient, but not mandatory. For example, function a () {alert (arguments [0] + arguments [1]);} functions in JavaScript are not overloaded. Therefore, when you define an overloaded function: the next function will overwrite the previous function. In fact, a function that does not return a Value Returns a special undefined value.
<SCRIPT type = "text/JavaScript"> // <! [CDATA [
VaR A = F;
Function f () {alert (1 );
}
Alert (2 );
Alert ()
//]> </SCRIPT>
In fact, only 2 and function f () {alert (1); are output, because f assigns the function to him and is not called. In fact, to call a function, a () must be added. If there is no (), it indicates that a is still the previous function type,
Unless the value is given again, it is useless for a or var A. A is still of the function type.
}
You can think of JavaScript function parameters as local variables.