The DOM (Document Object model) is the official standard for accessing HTML elements.
Window.alert () Pop-up warning box.
The document.write () method writes the contents to an HTML document.
InnerHTML writes to an HTML element.
Console.log () writes to the browser's console.
Three types of variable naming conventions:
var firstName= ' King ';//Small Hump
var FirstName= ' Queen ';//Big Hump
var first_name= ' maizi ';//Underline method
JavaScript is a scripting language. The browser executes the script code on a line-by-row basis when reading the code. For traditional programming, all code is compiled before execution.
Use JavaScript script to output a string in the page, write JavaScript script in HTML comment, if browser support JavaScript will output this string, if not support will not output this string
If you re-declare a JavaScript variable, the value of the variable is not lost:
After the following two statements are executed, the value of the variable carname remains "Volvo":
var carname= "Volvo";
var carname;
Let allows you to declare a variable, statement, or expression that has a scope that is limited to the block level. The Let variable is recommended for local variables in function to avoid variable name collisions.
A let declaration's variable is only available in its declared block or sub-block, which is similar to Var. The main difference between the two is that the variable declared by Var is scoped to the entire enclosing function.
If you want to access the FullName property of the person object, it is returned as a string that defines the function:
name = Person.fullname;
The properties in the JavaScript object are unique (the properties here include methods), and if there are two duplicate attributes, the last assignment will prevail
If you assign a value to a variable that has not been declared, the variable is automatically declared as a global variable.
This statement:
carname= "Volvo";
A global variable is declared carname, even if it executes within the function.
Before being called for the first time, the variable is nonexistent, that is, undefined. Func () becomes a global variable after it has been called.
Do not create a String object. It slows down execution speed and may have other side effects
= = = is absolutely equal, that is, the data type and value must be equal.
The result symbol of the modulo operation is only related to the symbol of the left value
Numbers are added to null (null values), and Null is converted to the number 0
The string is added with null (null value) and NULL is converted to a string:
Null is a special type with only one value. Represents an empty object reference.
undefined is a variable that has no value set.
The values of null and undefined are equal, but vary in type:
The data type of NaN is number
You can use the constructor property to see if an object is an array (containing the string "Array"):
You can use the instanceof operator to determine the object's specific type, syntax format: var result = objectName "variable name" instanceof objectType "type name"
JS preparations for spring recruit three