当前位置:网站首页>记录都有哪些_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
边栏推荐
猜你喜欢
七夕邂逅爱,那人一定在
《C 陷阱与缺陷 》阅读概要
MySQL性能指标TPS\QPS\IOPS如何压测?
"Social Enterprises Conducting Civilian Personnel Training Specifications" group standard on the shelves of Xinhua Bookstore
如何通过使用“缓存”相关技术,解决“高并发”的业务场景案例?
RK1126编译gdb 板子上gdb调试程序
一文梳理NLP主要模型发展脉络
相似文本聚类与调参
做项目管理有且有必要了解并学习的重要知识--PMP项目管理
How to find the location of a pdf file in endnote literature
随机推荐
router---路由守卫
考研上岸又转行软件测试,从5k到13k完美逆袭,杭州校区小哥哥拒绝平庸终圆梦!
零基础可以转行软件测试吗 ?这篇文章告诉你
秋招攻略秘籍,吃透25个技术栈Offer拿到手软
文字编码 - XML 教程
文盘Rust -- 配置文件解析
Various problems with npm install
干掉visio,这个画图神器真的绝了
odoo13笔记点
How to find the location of a pdf file in endnote literature
PAT甲级:1038 Recover the Smallest Number
SCA兼容性分析工具(ORACLE/MySQL/DB2--->MogDB/openGauss/PostgreSQL)
错误 AttributeError type object 'Callable' has no attribute '_abc_registry' 解决方案
zabbix自定义图形
新 Nsight Graph、Nsight Aftermath 版本中的性能提升和增强功能
七夕邂逅爱,那人一定在
漏洞复现 - - - Alibaba Nacos权限认证绕过
router---Programmatic navigation
Is the code more messy?That's because you don't use Chain of Responsibility!
【LeetCode】1403. 非递增顺序的最小子序列