当前位置:网站首页>Judge whether the beginning and end of the string contain target parameters: startswith() and endswith() methods
Judge whether the beginning and end of the string contain target parameters: startswith() and endswith() methods
2022-04-23 07:45:00 【Senior salted fish~】
startsWith(): Indicates whether the parameter string is in the of the original string Head , return Boolean value
endsWith(): Indicates whether the parameter string is in the of the original string The tail , return Boolean value
application :
let str = 'wo?e'
console.log(str.endsWith()); // false
console.log(str.startsWith('w')) //true
console.log(str.startsWith('')) //true
console.log(str.endsWith('')) //true
console.log(str.endsWith('e')) //true
console.log(str.endsWith('?', 3)); // true
From the example we can see :
1、 When a string calls endsWith()
When the method does not pass parameters , The default is undefined
The result is false;
2、 When looking for an empty string , The result is true, That's because empty characters exist in any string ;
3、 When there is a second parameter , The second parameter is the length of the string , The second parameter will take the specified length of the original string as the target string .
版权声明
本文为[Senior salted fish~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230623086845.html
边栏推荐
- Authorization server (simple construction of authorization server)
- 【TED系列】一个习惯是如何改变我的一生
- How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)
- js之什么是事件?事件三要素以及操作元素
- js之预解析
- F-牛妹的苹果树(直径合并)
- Super classic & Programming Guide (red and blue book) - Reading Notes
- 7. sub query
- 常用的DOS命令
- SAP ECC连接SAP PI系统配置
猜你喜欢
int a = 1存放在哪
keytool: command not found
js之节点操作,为什么要学习节点操作
SAP CR传输请求顺序、依赖检查
SAP TRANSLATE使用数据对象掩码示例
简易随机点名抽奖(js下编写)
Visualization Road (IX) detailed explanation of arrow class
SAP 导出Excel文件打开显示:“xxx“的文件格式和扩展名不匹配。文件可能已损坏或不安全。除非您信任其来源,否则请勿打开。是否仍要打开它?
On BFC (block formatting context)
SAP PI/PO Soap2Proxy 消费外部ws示例
随机推荐
Understanding of STL container
SAP PI/PO功能运行状态监控检查
King glory - unity learning journey
MySQL index
js之预解析
定位、修饰样式
OpenGL超级宝典初步配置(freeglut、glew、gltools、glut)
刨根问底---cocos2d源码的理解与分析
8. Paging query
Design optimization of MySQL database
学会使用搜索引擎
SAP PI/PO rfc2RESTful 发布rfc接口为RESTful示例(Proxy间接法)
instanceof的实现原理
Mysql 索引
游戏辅助脚本开发之旅
BTREE, B + tree and hash index
redis连接出错 ERR AUTH <password> called without any password configured for the default user.
防抖和节流
Super classic & Programming Guide (red and blue book) - Reading Notes
14.事务处理