One Variable
Use the VaR keyword inside the function body to define local variables.
Binary Value
Math. Round (), math. Floor (), and math. Ceil ()
Math. Random ()
Math. Abs ()
Tofixed ()
Parseint () and parsefloat ()
Three strings
You can use single or double quotation marks. If the quotation marks in a string are necessary, escape them.
Available methods and Properties of string objects
Length, indexof () and lastindexof (), charat (), substring (), split (), tolowercase (), touppercase ()
Four-Structure Control
If, elseif, switch (switch must have the same data type, similar to =)
For, while, do while, break and continue
Try catch finally
Five functions
Functions can also be passed as variables.
Vi. Object
7. event registration
1 inline Event Handlers <a href = "somewhere.html" onclick = "highlightnavitem ()">
2 The traditional model
<A href = "somewhere.html" id = "somewhere">
VaR x = Document. getelementbyid ('somewhere ');
X. onclick = highlightnavitem; // Note: No parentheses
3 executing Event Handlers directly
X [I]. onkeyup = x [I]. onchange = checkmaxlength;
X [I]. onkeyup ();
4 anonymous Functions
5 W3C and Microsoft Models