当前位置:网站首页>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++; } |
边栏推荐
- Income in the first month of naked resignation
- 将恶意软件嵌入到神经网络中
- 【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
- [learning notes] numerical differentiation of back error propagation
- On the confrontation samples and their generation methods in deep learning
- 用全连接层替代掉卷积 -- RepMLP
- Sorting out dialectics of nature
- 【BiSeNet】《BiSeNet:Bilateral Segmentation Network for Real-time Semantic Segmentation》
- 【DIoU】《Distance-IoU Loss:Faster and Better Learning for Bounding Box Regression》
- What if the laptop task manager is gray and unavailable
猜你喜欢
【Mixup】《Mixup:Beyond Empirical Risk Minimization》
Semi supervised mixpatch
Eklavya -- infer the parameters of functions in binary files using neural network
【Hide-and-Seek】《Hide-and-Seek: A Data Augmentation Technique for Weakly-Supervised Localization xxx》
[learning notes] numerical differentiation of back error propagation
【Batch】learning notes
【Paper Reading】
Sequence problem for tqdm and print
【Sparse-to-Dense】《Sparse-to-Dense:Depth Prediction from Sparse Depth Samples and a Single Image》
【MagNet】《Progressive Semantic Segmentation》
随机推荐
[Sparse to Dense] Sparse to Dense: Depth Prediction from Sparse Depth samples and a Single Image
【学习笔记】Matlab自编图像卷积函数
关于原型图的深入理解
How gensim freezes some word vectors for incremental training
静态库和动态库
[mixup] mixup: Beyond Imperial Risk Minimization
Real world anti sample attack against semantic segmentation
Several methods of image enhancement and matlab code
How do vision transformer work? [interpretation of the paper]
【Paper Reading】
【双目视觉】双目立体匹配
Pointnet understanding (step 4 of pointnet Implementation)
C # connect to MySQL database
It's great to save 10000 pictures of girls
Where do you find the materials for those articles that have read 10000?
Look for we media materials from four aspects to ensure your creative inspiration
【Random Erasing】《Random Erasing Data Augmentation》
CPU register
Open3d learning note 3 [sampling and voxelization]
将恶意软件嵌入到神经网络中