当前位置:网站首页>Array and string processing, common status codes, differences between PHP and JS (JS)
Array and string processing, common status codes, differences between PHP and JS (JS)
2022-07-02 08:00:00 【Rivers smile】
Personally collated from 2019 year , Although it looks untidy , But true and reliable , Self use
Catalog
splice
When a negative number is used as an argument, it means counting from the end of the array . When the second optional parameter is omitted , Means to copy to the end of the array . So use on arrays slice(-1) You can get the last element of the array .(-1 Last element ,-2 The second last element )
var args = [1, 2, 3];
var lastElement = args.slice(-1);//3
Delete current element arr.slice(i,1)


pop() Method
pop() Method , Delete the last element of the array and return it Using this method, we can get the last one of the array , Empathy shift() You can get the first one in the array (shift() Delete the first element of the array and return that element )
var arr=[1,2,3];
arr.pop() // Delete the last element of the array and return the deleted element 3
String segmentation
this.local_get=[12,22,33]
var arrayA = this.local_get.split(",");Remove the characters
math
Status code
1**: Request received , To continue processing
2**: Operation successfully received , analysis , Accept
3**: Further analysis is required to complete this request
4**: The request contains a bad syntax or cannot be completed
5**: The server failed to execute a fully valid request
100: Customer must continue to request
101: The client requires the server to convert according to the request HTTP Protocol version
200: Successful trade
201: Mention that you know the new document URL
202: To accept and deal with 、 But the processing is not complete
400: Wrong request , Such as grammatical errors
401: Request authorization failed
402: Keep valid ChargeTo Head response
403: The request does not allow
404: No documents found 、 Query or URL
Php js The difference between
js | php | |
notes | //.. /* */ | //.. /* */ |
Defining variables | var sum=2; | $sum=2; |
console.log(sum); | echo $sum: | |
function | Direct shortcut key open | Put the code in the server , Then in the matching browser 127.0.0.1 find |
Define an array , And print | var arr=[1,2,'a']; console.log(arr); | $arr=array(1,3,'5'); print_r($arr); echo $arr[1]; |
Line break | <br> | echo '<br>'; |
object | var person={ 'name':'tom', 'age':13, 'sex':' male ' }; | $person=array('name'=>'tom', 'age'=>13, 'sex'=>' male '); |
if | var age=18; if(age>=18){ console.log( ' adults '); }else{ console.log(' minors '); } | $age=18; if($age>=18){ echo ' adults '; }else{ echo ' minors '; } |
Three orders | var age=12; var res=(age>=18)? ' adults ':' A minor '; console.log(res); | $age=12; $res=($age>=18)? ' adults ':' A minor '; echo $res; |
switch | var age=18; switch(age){ case 0: console.log(' A minor '); break; case 18: console.log( ' adults '); break; default: console.log(0); } | $age=18; switch($age){ case 0: echo ' A minor '; break; case 18: echo ' adults '; break; default: echo '0'; } |
for | A little | $arr=array(1,2,4); for($i=0;$i<count($arr);$i++){ echo $arr[$i]; echo '<br>'; } |
while | A little | $arr=array(1,2,4); $index=0; while($index<count($arr)){ echo $arr[$index]; echo '<br>'; $index++; } |
边栏推荐
- 【学习笔记】Matlab自编图像卷积函数
- The hystrix dashboard reported an error hystrix Stream is not in the allowed list of proxy host names solution
- 【Cascade FPD】《Deep Convolutional Network Cascade for Facial Point Detection》
- MySQL优化
- 【MagNet】《Progressive Semantic Segmentation》
- Where do you find the materials for those articles that have read 10000?
- 【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》
- 联邦学习下的数据逆向攻击 -- GradInversion
- It's great to save 10000 pictures of girls
- 【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
猜你喜欢

Several methods of image enhancement and matlab code

Hystrix dashboard cannot find hystrix Stream solution

C语言实现XML生成解析库(XML扩展)
![[learning notes] numerical differentiation of back error propagation](/img/1c/e28e31d7cc5ccc38607c7839ccc5f0.png)
[learning notes] numerical differentiation of back error propagation

【Cutout】《Improved Regularization of Convolutional Neural Networks with Cutout》

Mmdetection trains its own data set -- export coco format of cvat annotation file and related operations

【Mixed Pooling】《Mixed Pooling for Convolutional Neural Networks》

【MagNet】《Progressive Semantic Segmentation》

【雙目視覺】雙目矯正

How to turn on night mode on laptop
随机推荐
Mmdetection trains its own data set -- export coco format of cvat annotation file and related operations
In the era of short video, how to ensure that works are more popular?
Nacos service registration in the interface
【Paper Reading】
AR系统总结收获
包图画法注意规范
业务架构图
Where do you find the materials for those articles that have read 10000?
業務架構圖
Sequence problem for tqdm and print
[learning notes] matlab self compiled image convolution function
简易打包工具的安装与使用
【Mixup】《Mixup:Beyond Empirical Risk Minimization》
【TCDCN】《Facial landmark detection by deep multi-task learning》
解决jetson nano安装onnx错误(ERROR: Failed building wheel for onnx)总结
【Wing Loss】《Wing Loss for Robust Facial Landmark Localisation with Convolutional Neural Networks》
What if the laptop can't search the wireless network signal
【Cascade FPD】《Deep Convolutional Network Cascade for Facial Point Detection》
Replace self attention with MLP
使用C#语言来进行json串的接收
