The content this article brings to you is about JavaScript entry to proficiency. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
#What is javascript?
JavaScript is a scripting programming language in web development. It is also a universal, cross-platform, object- and event-driven scripting language with security.
The main features of JavaScript:
Interpretive, object-based, event-driven, cross-platform, security
Applications of JavaScript:
Verify user input, animation effects, window applications, text special effects, etc.
Methods for using JavaScript in the web interface:
In the page Directly embed JavaScript code
Language is specified in Which scripting language is used in HTML and its version
Src specifies the path to the external script. External script files usually use javascript scripts with an extension of . js
Type specifies which scripting language and version are used in HTML. This attribute has been used since the HTML4.0 standard. It is recommended to use the type attribute instead of the language attribute.
Defer The function of this attribute is when After the document is loaded, the script is executed. When the script does not need to be executed immediately, after setting the defer attribute, the browser will not have to wait for the script language to be loaded, so that the mask will load faster.
Connecting external JavaScript File
<script language="javascript" src="javascript.js"></script>
JavaScript basic syntax
The Javascript program is executed line by line in the order it appears in the html view
If necessary, To execute in the entire html file, it is best to place the file in the
tag of htmlJavascript is very sensitive to the case of letters
The semicolon at the end of each line is optional None
Identifier: It’s just a name
Keyword: It has a specific meaning in javascript
Constant: A quantity whose value cannot be changed while the program is running
Variable: refers to a named storage unit in the program
The naming of variables
Declaration and assignment of variables
Variables in JavaScript all have var To declare, the format is: var a;
Declare variables and assign values: var b=2;
var You can declare multiple variables at the same time
var a,b, c
var declares multiple variables at the same time and assigns values:
var a=1,b=2,c=3;
The scope of the variable
The lifetime of a variable: refers to the valid time the variable exists in the computer
Global variables: always valid during program execution
Local variables: the valid scope of the variable is only within the current function中
Data type
Number (Number) is the most basic data type. In JavaScript, there is no distinction between integer and floating-point values. All numbers are composed of floating-point values. Represents
When a number appears directly in a javascript program, it is called a numerical direct quantity
The numerical direct two forms supported by JAVASCRIPT are as follows:
integer Type data
Hexadecimal and octal
Floating point data
String type
String (String) is composed of Unicode characters, numbers , a sequence composed of punctuation marks, etc., which is the data type used by JavaScript to represent text
Contained in single quotes or double quotes
Boolean data
The value has only two , true, false are used to indicate whether something is true or false
Special data type
Escape characters
Undefined value undefined
Special The type of numeric constant NaN, that is, not a number, is a number generated due to a calculation error in the program.
Null value
Null means null value
Null is not equivalent The empty string "" or 0
Null means that a variable has been assigned a null value, while undefined means that the variable has not been assigned a value
Operator
here I won’t spell it out in detail, anyone who can program knows that
Operators in Javascript can be divided into single-objective operations, binocular operations, and multi-objective operations according to the operands
According to the operation type, they can Divided into arithmetic operators, comparison operators, assignment operators, logical operators, conditional operators
trinary operations
(a==b)? Correct: Error
A is equal to b, return correct
A is not equal to b, return error
Other operators:
bit operator
Typeof operator
The Typeof operator is used to return the type of data currently held by its operand. Often used to determine whether a variable is defined
<script language="javascript"> var a = 3; alert("a的类型为"+(typeof a)) <script>
New operator
Used to create a new object
Expression
The above is for JavaScript All introductions from entry to proficiency. If you want to know more about CSS3 tutorials, please pay attention to the PHP Chinese website.
The above is the detailed content of From beginner to proficient in JavaScript, you only need to learn so much. For more information, please follow other related articles on the PHP Chinese website!