- 19
- 0
- 约6.54千字
- 约 9页
- 2017-08-15 发布于河南
- 举报
js语句及语法(JS statements and syntax)
js语句及语法(JS statements and syntax)
The statements provided by JavaScript fall into the following categories:
1. variables declaration, assignment statement: var.
The syntax is as follows: VAR variable name [= initial value]
For example: VAR computer = 32 / / computer definition is a variable, and the initial value is 32.
2. function definition statement: function, return.
The syntax is as follows: the function function name (the arguments that the function takes)
{
Function execution section
}
The return expression //return statement specifies the value to return.
Example: function square (x)
{
Return x*x
}
3. condition and branch statement: if... Else, switch.
The if... Else statement completes the branching function of the program flow block: if the condition is established, the program executes the conditional statement or block of statements immediately; otherwise, the program executes the statement or block of statements in else. Syntax is as follows: if (condition)
{
Execute statement 1
Else{}
Execute statement 2
}
For example: if (result = true)
{
Response = you got the right answer!
Else{}
Response = youre wrong!
}
Branch statement switch can be handled differently depending on the different values of a variable.
The syntax is as follows: switch (expression)
{
Case label1: statement string 1;
Case label2: statement string 2;
Case label3: statement string 3;
...
Default: statement string 3;
}
If the value taken by the expression does not match any statement provided in the program, the statement in the default is executed.
4. loop statements: for, for, in, while, break, continue.
The syntax of the for statement is as follows: for (initialization section, conditional part, update part)
{
Executive part...
}
As long as the condition of the cycle is established, the loop body is repeatedly executed.
The for... In statement is a little different from the for statement, which ranges from all attributes of an object or to all elements of an array.
The syntax for for
您可能关注的文档
- joo1(joo1).doc
- java面试纠错题目大全(Java interview error correction topics).doc
- jorinde and joringel(jorinde和joringel).doc
- js document对象(i document对象).doc
- jdbc 访问各种数据库 url 语法(总结篇)(JDBC access various database URL syntax (summary)).doc
- java面象对象编程(Java object like programming).doc
- jsp input限制输入(JSP input restrict input).doc
- juniper基本配置入门(Introduction to basic configuration of juniper).doc
- js语法(JS syntax).doc
- jtgkuy(jtgkuy).doc
- 河北盐山中学等校2025-2026学年上学期高三一模化学试卷(含解析).docx
- 河北正定中学2025-2026学年高一上学期期末考试物理试卷(含解析).docx
- 河北张家口市怀安县2025-2026学年第一学期期末教学综合评价八年级地理试卷(含解析).docx
- 河南安阳市殷都区2025-2026学年第一学期期末教学质量检测七年级地理试卷(含解析).docx
- 河南安阳市滑县2025一2026学年第一学期期末学业质量监测八年级地理试题(含解析).docx
- 河南安阳市林州市2025-2026学年上学期期末考试高一政治试题(含解析).docx
- 河南焦作市武陟县第一中学2025-2026学年高一上学期1月月考语文试卷(含解析).docx
- 河南济源市2025-2026学年上学期期末学业质量调研七年级历史试卷(含解析).docx
- PICC导管并发症的紧急处理与护理.pptx
- 河南鹤壁市2025-2026学年高二上学期期末考试生物试题(含解析).docx
原创力文档

文档评论(0)