当前位置: 首页 > news >正文

字符串函数的运用

<!DOCTYPE html>
<html lang="zh - CN"><head><meta charset="UTF - 8"><meta name="viewport" content="width=device-width, initial - scale=1.0"><title>字符串函数示例</title>
</head><body><script>// charAt() 示例
        let str1 = "Hello";console.log("charAt() 示例:" + str1.charAt(1));// charCodeAt() 示例
        let str2 = "World";console.log("charCodeAt() 示例:" + str2.charCodeAt(0));// concat() 示例
        let str3 = "Hello";let str4 = " World";console.log("concat() 示例:" + str3.concat(str4));// fromCharCode() 示例
        console.log("fromCharCode() 示例:" + String.fromCharCode(65, 66, 67));// indexOf() 示例
        let str5 = "abcabc";console.log("indexOf() 示例:" + str5.indexOf('b'));// lastIndexOf() 示例
        console.log("lastIndexOf() 示例:" + str5.lastIndexOf('b'));// localeCompare() 示例
        let str6 = "apple";let str7 = "banana";console.log("localeCompare() 示例:" + str6.localeCompare(str7));// match() 示例
        let str8 = "I love JavaScript";console.log("match() 示例:" + str8.match(/love/));// replace() 示例
        let str9 = "The cat is cute";console.log("replace() 示例:" + str9.replace("cat", "dog"));// search() 示例
        let str10 = "Find the keyword";console.log("search() 示例:" + str10.search(/keyword/));// slice() 示例
        let str11 = "JavaScript is fun";console.log("slice() 示例:" + str11.slice(0, 10));// split() 示例
        let str12 = "apple,banana,cherry";console.log("split() 示例:" + str12.split(','));// substr() 示例
        let str13 = "Substring example";console.log("substr() 示例:" + str13.substr(0, 5));// substring() 示例
        let str14 = "Another substring example";console.log("substring() 示例:" + str14.substring(0, 5));// toLocaleLowerCase() 示例
        let str15 = "HELLO";console.log("toLocaleLowerCase() 示例:" + str15.toLocaleLowerCase());// toLocaleUpperCase() 示例
        let str16 = "hello";console.log("toLocaleUpperCase() 示例:" + str16.toLocaleUpperCase());// toLowerCase() 示例
        let str17 = "UpperCase";console.log("toLowerCase() 示例:" + str17.toLowerCase());// toString() 示例
        let num = 123;console.log("toString() 示例:" + num.toString());// toUpperCase() 示例
        let str18 = "lowercase";console.log("toUpperCase() 示例:" + str18.toUpperCase());// trim() 示例
        let str19 = "   Trim me   ";console.log("trim() 示例:" + str19.trim());// valueOf() 示例
        let strObj = new String("ValueOf example");console.log("valueOf() 示例:" + strObj.valueOf());</script>
</body></html>

 

http://www.gsyq.cn/news/57917.html

相关文章:

  • 关于字符
  • 云数据仓库十年架构演进与技术革新
  • HTML 图片的放大和缩小
  • 数据科学团队领导指南-全-
  • HTML 大写转小写
  • 图片3:字符串属性表
  • Mac 安装 Anaconda3-2020.02.dmg 教程(从下载到 conda 可用)
  • 生命空间转移器
  • 2025年11月建筑排水管品牌综合评测:聚鑫管业领跑行业十大品牌
  • 一种45度机翼的重力作用点和气流作用点合一的喷气式飞机
  • HTML----------------字符串
  • 快速上手大模型:深度学习1(初识、神经网络基础) - 详解
  • 深入解析:【AUTOSAR以太网】EthSM简介
  • 2025年靠谱的数控弹簧机行业内知名厂家排行榜
  • 微型锌空气电池为细胞级机器人供电
  • 2025年口碑好的道路照明工程实力企业榜单
  • 2025年比较好的异性包装印刷用户信赖优选榜
  • 2025年靠谱的钢珠轨厂家实力及用户口碑排行榜
  • 苏州交通事故律所推荐:专业法律服务机构选择参考
  • 杭州公司注册银行开户哪家强?本地服务机构实力参考
  • abc433
  • Flutter 问题诊断-0.1
  • AI生成图像在形状识别中的荒谬表现
  • liviv
  • 重回单体,真的不是技术倒退 - 智慧园区
  • int在python是什么
  • intel linux 驱动
  • instr sql函数能实现啥
  • instr sql函数如何用
  • Inode怎样影响MySQL的数据恢复