当前位置:网站首页>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 .
边栏推荐
- vsftpd服务的部署及优化
- Xshell and xftp tutorial
- 工作组环境下的内网渗透:一些基础打法
- 董宇辉,新东方以及凤凰卫视
- TiDB v6.0.0 (DMR) :缓存表初试丨TiDB Book Rush
- This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错
- MySQL cannot query the maximum value using the max function
- Graduation season, some suggestions for you who are new to the society
- [sword finger offer] 49 Ugly number
- 近况
猜你喜欢

Yann Lecun's new paper: the road to building automatic agents

培训通知|2022年境外中资企业机构及人员疫情防控和安全防范专题培训通知

远程登录sshd服务

ThreadLocal的简单理解

Training notice | special training notice on epidemic prevention and security prevention for overseas Chinese funded enterprises, institutions and personnel in 2022

Zero foundation self-study SQL course | if function
This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错

Fancy features and cheap prices! What is the true strength of Changan's new SUV?

Word、PDF、TXT文件实现全文内容检索需要用什么方法?

Get current system date
随机推荐
Mysql安装配置以及解决重装Mysql时忘记root password问题
For example, the visual appeal of the live broadcast of NBA Finals can be seen like this?
Fancy features and cheap prices! What is the true strength of Changan's new SUV?
ProCAST有限元铸造工艺模拟软件
Xshell and xftp tutorial
Solve the problem of reading package listsdonebuilding dependency treereading state informationdone
Redis6 一:Nosql引入、Redis可以解决什么问题?
东方财富手机股票开户哪个券商更安全更方便?
day28 严格模式、字符串 js 2021.09.22
如临现场的视觉感染力,NBA决赛直播还能这样看?
【无标题】虚拟机vmnet0找不到且报错:没有未桥接的主机网络适配器
MySql5.7添加新用户
Summary of spatial temporal time series prediction modeling methods
Basic 02: variable, remember the mobile number of the object
科研丨Web of Science检索技巧
Adding a new user in MySQL 5.7
动态库(共享库)的制作和使用
基于验证码识别的机器学习项目captcha_trainer操作实践
利用soapUI获取freemarker的ftl文件模板
Splicing strings in the string collection_ Stream based