当前位置:网站首页>Day28 strict mode, string JS 2021.09.22
Day28 strict mode, string JS 2021.09.22
2022-06-28 11:30:00 【Little dream of becoming a big man】
ES5 The strict model of : Use the syntax : "use strict";
Instructions :
-- Put it at the top of the code , That is to say script The first line in a tag or a function , Otherwise it will fail
-- Strict mode can regulate the current script Tag or code in the current function , Can not regulate other script The code in the tag and other functions
Standard grammar :
Implicit declaration of variables... Is not allowed
It is forbidden to duplicate the names of formal parameters in functions
Disable in function this representative window
Why use strict patterns ?
It can make the code more standardized
It can make the code run faster , Improve operational efficiency
Be careful : When merging files , The strict mode code in the first line is invalid , It is recommended that the package be in a self executing function
character string :
Through the asker code table , We can get some rules of string comparison :
-- Letters are larger than numbers
-- Lowercase letters are larger than uppercase letters
-- The letters get bigger as they come back
Common methods of string :
charAt( Subscript ): Get the corresponding characters in the string by subscript
- The string is also subscripted It can be done by string [ Subscript ] Get the corresponding characters
- Strings are just readable States , You cannot modify or add
- Strings can also be looped
charCodeAt( Subscript ): Get the corresponding character by subscript ASCII
String.fromCharCode(unicode code ): adopt ASCII Get character , Multiple encodings are separated by commas .
split( Segmentation symbols ): According to the separator 、 Split the string into an array .
- split In parentheses, except for the division symbol , You can also separate them with commas followed by a parameter number type It means to keep several data
substring( The starting subscript , Ending subscript ): Used to intercept the contents of a string
- Start subscript contains The ending subscript does not contain
- If the end subscript of the second parameter is not written It means that all characters from the beginning to the end will be intercepted
- When the start subscript and the end subscript are equal, it will return ' empty '
- When the start subscript is greater than the end subscript , The two parameters will be exchanged and intercepted
- If the subscript is negative , The default conversion is 0 Then intercept
substr(start, length): Used to intercept the contents of a string
- The number of ends can also be omitted Omission means that everything from the current subscript to the following is intercepted
slice( Start subscript , End subscript ): The way to intercept a string , If it's negative , Intercept from back to front , Include the starting index .
- Start subscript contains The ending subscript does not contain
- The second parameter is optional If you don't write, it means to intercept to the end
- Both parameters can be negative numbers
- The first parameter is greater than the second parameter Returns an empty
- The first parameter is less than the second parameter
indexOf() The position of the first occurrence of a character
laseIndexOf() The last position of the character
concat( ): Consistent with array method .
grammar : character string .concat( Spliced string )
toUpperCase(): Convert to uppercase .
toLowerCase(): Convert to lowercase .
边栏推荐
- Cannot redeclare block range variables
- 关于Pytorch中双向LSTM的输出表示问题
- This Exception was thrown from a job compiled with Burst, which has limited exception support. report errors
- 2022中国信通院首届业务与应用安全发展论坛成功召开!
- 毕业季 新的开始
- [sciter]:sciter如何使用i18实现桌面应用多语言切换及其利弊
- Scientific research - web of science retrieval skills
- day29 js笔记 2021.09.23
- 什么是DAPP系统发展与解析理解
- GCC简介
猜你喜欢

JS foundation 3

Class pattern and syntax in JS 2021.11.10

Making and using of dynamic library (shared library)

远程登录sshd服务
This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错

Tidb v6.0.0 (DMR): initial test of cache table - tidb Book rush

Get current system date

Recommended practice sharing of Zhilian recruitment based on Nebula graph

Cannot redeclare block range variables

Solve the problem of reading package listsdonebuilding dependency treereading state informationdone
随机推荐
Xshell and xftp tutorial
零基础自学SQL课程 | IF函数
[semidrive source code analysis] [x9 chip startup process] 32 - play module analysis - RTOS side
Unity屏幕截图功能
买股票在中金证券经理的开户二维码上开户安全吗?求大神赐教
Download and install mysql5.7 for windows 10
2022中国信通院首届业务与应用安全发展论坛成功召开!
js中的数组方法 2021.09.18
MySQL installation configuration and solving the problem of forgetting root password when reinstalling MySQL
董宇辉,新东方以及凤凰卫视
一套十万级TPS的IM综合消息系统的架构实践与思考
《运营之光3.0》全新上市——跨越时代,自我颠覆的诚意之作!
使用logrotate对宝塔的网站日志进行自动切割
Training notice | special training notice on epidemic prevention and security prevention for overseas Chinese funded enterprises, institutions and personnel in 2022
Analyze whether there is duplicate data in the list and repeat it several times
JS foundation 4
JS foundation 6
无法重新声明块范围变量
Makefile简介
Xshell和Xftp使用教程