当前位置:网站首页>The sixth training assignment
The sixth training assignment
2022-07-07 10:57:00 【m0_ sixty-three million five hundred and fifty-two thousand nin】
1. Operator
Operators are used to perform program code operations . Will operate on one or more operands
2. Control statement
We wrote javascript The code is carried out from top to bottom , Many times we want the code to execute as we want , For example, selectively execute some code , This requires the use of process control statements .
There are three kinds of process statements :
1. Process execution : From top to bottom , From left to right
2. Choose to perform : Branch selection
3. Loop execution : repeat
3. choice
3.1 Single choice
if( Conditions ){
Statement of body :
}
First, execute the condition
If the result is true, Then execute the statement body 1
If the result is false, Then execute the statement body 2
3.2 Multiple choice
if( Comparison expression 1){
Statement of body 1
}else if( Comparison expression 2){
Statement of body 2;
}else if( Comparison expression 3){
Statement of body 3;
}
3.3switch
Multiple if.....else And the value is constant , It can be used switch Replace :
switch( expression ){
case value 1;
Statement of body 1;
break;
case value 2;
Statement of body 2;
break;
default:
Statement of body n+1;
[break;]
}
break Prevent penetration , without break, Then continue to execute the following code , Until I met break Or complete the execution , But sometimes penetration is used
3.4 loop
The loop structure is used to repeat an operation , Simple to understand is to repeatedly execute the same type of code , He has many forms :
1.while: Execute before judge
2.do.....while: Judge before you execute , At least once
3.for:for( Initialization statement ; Judgment statement ; Control condition statement ){
Loop body statement ;
}
4. Dead cycle : Conditions are always there , For ever true, There will be a life and death cycle
5.break And continue
break: Stop this cycle
continue: Pause this cycle , Continue next time
4 Array
An array of data arranged in order , The position of each value has a number , The whole array is represented by brackets
4.1 To define an array
js There are three ways to define arrays in :
var arr=[1,2,3];
var arr=new Array(1,2,3);
var arr=new Array(size);
4.2 Basic operation
The length of the array can be determined by length Property to get , And you can change
4.3 Array traversal
Array traversal is to access each element in the array in turn ,js Provides three ways to traverse arrays :
1.for Loop traversal
2.for.....in
3.forEach
4. understand
4.4 The operation method provided by array
Array Object provides us with some methods , You can easily manipulate arrays
5. function
Functions as methods are pre-set blocks of code , It can be called repeatedly , According to the input parameters , Returns different values . Functions are also objects .
5.1 Function definition
There are three ways to define functions : Function declaration statement , Function definition expression ,function Constructors
5.2 Function declaration statement
function Function name ([ parameter list ]){
}
5.3 Function definition expression
Functions defined as expressions , The name of the function is unnecessary
var Variable name =function([ parameter list ])
5.4function Constructors
function Constructor accepts any number of arguments , But the last parameter is always regarded as a function body, also known as an expression , The previous parameters list the parameters of the new function
5.5 The parameters of the function
Sometimes, external data is required when a function is running , Different external data leads to different results , This kind of external data is called parameter , The parameters when defining are called formal parameters , The parameters when calling are called arguments
6. Function call
6.1 Commonly used call method
There is a return value that can be accepted by variables , If a function with no return value is accepted, it is unfined
2. Function call mode
3. Function call method
6.2return
Function execution may have a return value , Need to use return Statement to return the result to .return Statements are not necessary , If not, the function will not return any value
6.3 The scope of the function
Function scope : Global and local
1. The homonymy problem of global variables and local variables
2 When you define variables in a function , If not var keyword , After use, it will automatically become a global variable
边栏推荐
- 【推薦系統 01】Rechub
- Introduction to shell programming
- 打算参加安全方面工作,信息安全工程师怎么样,软考考试需要怎么准备?
- Application of OpenGL gllightfv function and related knowledge of light source
- How to play video on unityui
- Records on the use of easyflash v3.3
- July 10, 2022 "five heart public welfare" activity notice + registration entry (two-dimensional code)
- ADB utility commands (network package, log, tuning related)
- [dai6] mirror image of JZ27 binary tree
- [recommendation system 01] rechub
猜你喜欢

shardingsphere分库分表示例(逻辑表,真实表,绑定表,广播表,单表)
![[recommendation system 01] rechub](/img/92/c14c867247d3a042c69b5ed0091fbe.png)
[recommendation system 01] rechub

中级软件评测师考什么

无法打开内核设备“\\.\VMCIDev\VMX”: 操作成功完成。是否在安装 VMware Workstation 后重新引导? 模块“DevicePowerOn”启动失败。 未能启动虚拟机。

2021 summary and 2022 outlook

Mendeley--免费的文献管理工具,给论文自动插入参考文献

软考中级,软件设计师考试那些内容,考试大纲什么的?
![[pro test feasible] error while loading shared libraries solution](/img/e2/688ffa07861f38941cbf2cafdd9939.png)
[pro test feasible] error while loading shared libraries solution

Trajectory planning for multi robot systems: methods and Applications Overview reading notes

Seata 1.3.0 four modes to solve distributed transactions (at, TCC, Saga, XA)
随机推荐
2021 summary and 2022 outlook
2022.7.3DAY595
CAS mechanism
软考一般什么时候出成绩呢?在线蹬?
How to successfully pass the senior system architecture designer in the second half of the year?
Using tansformer to segment three-dimensional abdominal multiple organs -- actual battle of unetr
What are the test preparation materials and methods for soft exam information processing technicians?
【亲测可行】error while loading shared libraries的解决方案
Multithreaded asynchronous orchestration
China Southern Airlines pa3.1
Introduction to shell programming
【推荐系统 02】DeepFM、YoutubeDNN、DSSM、MMOE
Unity websocket server
Transaction rolled back because it has been marked as rollback-only解决
Operation method of Orange Pie orangepi 4 lts development board connecting SATA hard disk through mini PCIe
Unity downloads files through the server address
1324: [example 6.6] integer interval
【实战】霸榜各大医学分割挑战赛的Transformer架构--nnFormer
Unity websocket client
打算参加安全方面工作,信息安全工程师怎么样,软考考试需要怎么准备?