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

宿迁莱布拉网站建设网站根目录下

宿迁莱布拉网站建设,网站根目录下,宣讲家网站两学一做心得,网站建设论文提纲一、操作方法 我们也可将字符串常用的操作方法归纳为增、删、改、查#xff0c;需要知道字符串的特点是一旦创建了#xff0c;就不可变 增 这里增的意思并不是说直接增添内容#xff0c;而是创建字符串的一个副本#xff0c;再进行操作 除了常用以及${}进行字符串拼接之…一、操作方法 我们也可将字符串常用的操作方法归纳为增、删、改、查需要知道字符串的特点是一旦创建了就不可变 增 这里增的意思并不是说直接增添内容而是创建字符串的一个副本再进行操作 除了常用以及${}进行字符串拼接之外还可通过concat concat 用于将一个或多个字符串拼接成一个新字符串 let stringValue hello ; let result stringValue.concat(world); console.log(result); // hello world console.log(stringValue); // hello删 这里的删的意思并不是说删除原字符串的内容而是创建字符串的一个副本再进行操作 常见的有 slice()substr()substring() 这三个方法都返回调用它们的字符串的一个子字符串而且都接收一或两个参数。 let stringValue hello world; console.log(stringValue.slice(3)); // lo world console.log(stringValue.substring(3)); // lo world console.log(stringValue.substr(3)); // lo world console.log(stringValue.slice(3, 7)); // lo w console.log(stringValue.substring(3,7)); // lo w console.log(stringValue.substr(3, 7)); // lo worl改 这里改的意思也不是改变原字符串而是创建字符串的一个副本再进行操作 常见的有 trim()、trimLeft()、trimRight() repeat() padStart()、padEnd() toLowerCase()、 toUpperCase() trim()、trimLeft()、trimRight() 删除前、后或前后所有空格符再返回新的字符串 let stringValue hello world ; let trimmedStringValue stringValue.trim(); console.log(stringValue); // hello world console.log(trimmedStringValue); // hello worldrepeat() 接收一个整数参数表示要将字符串复制多少次然后返回拼接所有副本后的结果 let stringValue na ; let copyResult stringValue.repeat(2) // na na padEnd() 复制字符串如果小于指定长度则在相应一边填充字符直至满足长度条件 let stringValue foo; console.log(stringValue.padStart(6)); // foo console.log(stringValue.padStart(9, .)); // ......footoLowerCase()、 toUpperCase() 大小写转化 let stringValue hello world; console.log(stringValue.toUpperCase()); // HELLO WORLD console.log(stringValue.toLowerCase()); // hello world查 除了通过索引的方式获取字符串的值还可通过 chatAt() indexOf() startWith() includes() charAt() 返回给定索引位置的字符由传给方法的整数参数指定 let message abcde; console.log(message.charAt(2)); // cindexOf() 从字符串开头去搜索传入的字符串并返回位置如果没找到则返回 -1 let stringValue hello world; console.log(stringValue.indexOf(o)); // 4startWith()、includes() 从字符串中搜索传入的字符串并返回一个表示是否包含的布尔值 let message foobarbaz; console.log(message.startsWith(foo)); // true console.log(message.startsWith(bar)); // false console.log(message.includes(bar)); // true console.log(message.includes(qux)); // false二、转换方法 split 把字符串按照指定的分割符拆分成数组中的每一项 let str 122334 let arr str.split() // [12,23,34]三、模板匹配方法 针对正则表达式字符串设计了几个方法 match()search()replace() match() 接收一个参数可以是一个正则表达式字符串也可以是一个RegExp对象返回数组 let text cat, bat, sat, fat; let pattern /.at/; let matches text.match(pattern); console.log(matches[0]); // catsearch() 接收一个参数可以是一个正则表达式字符串也可以是一个RegExp对象找到则返回匹配索引否则返回 -1 let text cat, bat, sat, fat; let pos text.search(/at/); console.log(pos); // 1replace() 接收两个参数第一个参数为匹配的内容第二个参数为替换的元素可用函数 let text cat, bat, sat, fat; let result text.replace(at, ond); console.log(result); // cond, bat, sat, fat 参考文献  面试官JavaScript字符串的常用方法有哪些 | web前端面试 - 面试官系列 (vue3js.cn)
http://www.pierceye.com/news/737117/

相关文章:

  • app如何推广深圳网络排名优化
  • 网站seo规范南昌it制作电商网站的公司
  • 深圳网站设计 工作室深圳品牌设计工作室
  • 手机网站静态动态wordpress注意
  • 什么网站没人做v5shop微分销系统
  • 做鞋子的网站品牌vi设计包括哪些
  • 做产品类的工作上什么网站好asp.net做的网站模板下载
  • 金融公司网站规划方案我司网站改版上线网站建设
  • 城乡与住房建设部网站首页深圳响应式设计企业网站
  • 做网站 带宽 多少钱做电影网站的服务器需要多大
  • 西安网站建设全包用手机制作游戏的软件
  • 哪个网站生鲜配送做的好drupal wordpress网站
  • 网站后台需要多少建设部举报网站
  • 重庆建筑证书查询网站wordpress博客怎么访问不了
  • 网站案例鉴赏wordpress html5视频
  • 免费申请网站 主机 空间网站不稳定
  • 建立个人网站视频教程中国空间站和国际空间站对比
  • 佛山网站seo推广推荐一个专门做海鲜的网站
  • 长春网站建设与健网站外链如何做
  • 网站开发国内现状网站建设与维护教学计划
  • 如何解决网站图片打开慢网站如何做跳转
  • 网站开发作用大学生网络营销策划书
  • 有域名了如何建网站用自己的身份做网站备案
  • 免费的黄冈网站有哪些平台游戏软件上海网站建设自学
  • 网站建设摊销几年wordpress怎样建立二级菜单
  • 营销方案案例北京搜索引擎优化seo专员
  • 网站建设是什么科目wordpress 火车头
  • 做网站需要什么专业方向的员工wordpress yeti
  • 网站建设项目登记表长沙建网站培训机构
  • 拖拽建站平台福州小学网站建设