JS format and location :
<!--JS content can be in the head, can also be in the body, different positions in the order of execution will have a difference, but also can be placed in a single JS file,
This facilitates maintenance and modification, and can speed up the loading of HTML pages.
-
alert ("JS in Head"); </script>alert ("JS in Body"); </script></body>
# # Scope
The variables in JavaScript also have global variables and local variables.
Global variables are defined outside of all functions and are scoped to the entire JavaScript code;
A local variable is defined within the body of a function and is visible only to its function, but not to other functions.
# # # features : JS is a weak type language, do not define variable types can also be assigned, and can be used directly.
the repeating declaration of the # # function: If you repeatedly declare the same function using the functions command multiple times, the subsequent declaration overrides the previous declaration, and the last function is called multiple times, and the result of the following program is
2
2
...... <script>function my_func () {document.write (1);} My_func () document.write ("<br>"); function My_func () {document.write (2);} My_func ()</script> ...
One of JavaScript quick summaries