当前位置:网站首页>记录都有哪些_js常用方法总结
记录都有哪些_js常用方法总结
2022-08-04 13:49:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
记住几个js的api并不能提交自己的竞争力,但可以提高开发效率。
includes() 判断字符串中是否含有其他字符串,返回布尔类型值
const name = 'hy';
const sentence = 'Hello hy! I am lq.';
const result = sentence.includes(name);
console.log(result); // true
复制代码startsWith() 判断某个字符串是否在调用者的开头,返回布尔类型
sentence.startsWith('He'); // true
复制代码endsWith() 判断某个字符串是否在调用者的结尾,返回布尔类型
sentence.endsWith('lq.'); // true
复制代码replace()方法用来替换字符串中的子串
let name = 'repeat my name: liqi liqi liqi';
let result1 = name.replace('li', 'h');
console.log(name); // 'repeat my name: liqi liqi liqi'
console.log(result1); // 'repeat my name: hqi liqi liqi';
let result2 = name.replace(/li/g, 'h');
console.log(result2); // 'repeat my name: hqi hqi hqi';复制代码发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/106851.html原文链接:https://javaforall.cn
边栏推荐
- 【牛客刷题-SQL大厂面试真题】NO5.某宝店铺分析(电商模式)
- MPLS实验
- 信创是什么意思?涉及哪些行业?为什么要发展信创?
- Why don't young people like to buy Mengniu and Yili?
- 错误 AttributeError type object 'Callable' has no attribute '_abc_registry' 解决方案
- LeetCode 1403 Minimum subsequence in non-increasing order [greedy] HERODING's LeetCode road
- 文字编码 - Markdown 简明教程
- LeetCode_299_猜数字游戏
- odoo13笔记点
- MySQL性能指标TPS\QPS\IOPS如何压测?
猜你喜欢
随机推荐
router---动态路由匹配
How to stress the MySQL performance indicators TPS\QPS\IOPS?
LeetCode_3_无重复字符的最长子串
Utility function---string processing
节省50%成本!京东云重磅发布新一代混合CDN产品
信创是什么意思?涉及哪些行业?为什么要发展信创?
Cockpit human-computer interaction "undercurrent", voice "down", multi-modal "up"
并发刺客(False Sharing)——并发程序的隐藏杀手
TS - type
leetcode 48. Rotate Image 旋转图像(Medium)
做项目管理有且有必要了解并学习的重要知识--PMP项目管理
router---路由守卫
Install mysql on k8s
工具函数---字符串处理
项目里的各种配置,你都了解吗?
ROS设置plugin插件
[Niu Ke brush questions-SQL big factory interview questions] NO5. Analysis of a treasure store (e-commerce model)
新 Nsight Graph、Nsight Aftermath 版本中的性能提升和增强功能
卷积神经网络 基础
nVisual secondary development - Chapter 2 nVisual API operation guide Swagger use









