First, what is JavaScript
1, JavaScript concepts: JavaScript object-oriented event-driven scripting language has security, object-oriented
2, JavaScript features:
(1) an interpreted language, while running side to explain
(2) and HTML page to achieve interaction effect
(3) syntax similar to the Java
(4) a move for writing client-side script
3, JavaScript consisting of:
(1) ECMAScript: scripting language specification (standard)
(2) BOM browser Object model browser Object model
(3) DOM document Object model document Object model
Two .JavaScript basic grammar
Web server: Tomcat7 Resin into the Web server running the project
<script type="text/javascript"> document.write("初学JavaScript"); document.write("<he>Hello JavaScript</h1>"); </script>
Third, the data type of the variable and
1, the array
var value = prompt ( ': Please enter a username'); // input box
alert (value); // balloons
// Number
var number1 = 1.10000;
// String
var name = 'Wang Moutao';
// we can not see the data type of the variable to null but we can see the variable is null
// undefined undefined value or not to the
var XX;
// to true to false Boolean
var = in Flag to true;
// Object
var Array = new new the Array ( 'a', 'two');
// typeof data acquisition variable value or type of
alert (typeof null);
2, string type common methods:
Properties: Returns a string length string object .length
(1) charAt (index) Returns the character at the specified location
(2) indexOf (str, index ) to find the location of a specified string is first found in the string
(3) substring (index1, index2 ) Returns the specified index index2 and index1 between the string, and includes a character index corresponding to index1, index2 index does not include the corresponding character
(5) split (str) the string into a string array
3, array common methods:
properties: array object. length returns the length of the string
(1) join () to all elements of the array into a string, separated by a separator
(2) sort () to sort the array
(3) push () is added to the end of the array or a more elements, and returns the new length
Fourth, the selection structure and loop structure
1, if the structure
2, switch structure
3, for loop
4, while loop
5, do-while loop
6, for-in loop
Fifth, functions and events
1, the meaning of the function: The method is similar to Java, a block of code statements accomplish specific tasks
the parseInt ( "string")
2, to convert the string to an integer number
such as: parseInt ( "86") the string " 86 "is converted to an integer value 86
parseFloat (" string ")
3, the string is converted to floating point numbers
, such as: parseFloat (" 34.45 ") the string" 34.45 "into a floating point value 34.45
. 4, isNaN ( )
is used to check whether the parameter which is non-digital
Six events:
1, onload a page or an image is finished loading
2, onlick click an object
3, onmouseover mouse moves on a guide element
4, onkeydown of a keyboard key is pressed
5, the contents field is changed onchange