美文网首页
[记录] 字符串、数组处理方法总结

[记录] 字符串、数组处理方法总结

作者: 是ADI呀 | 来源:发表于2017-09-06 15:46 被阅读0次

title: 字符串、数组处理方法总结
date: 2017年9月6日 16:09:19
tags: js
categories: 教程
author: "JiaWei"


String转Array
let str = "Hello";
let arr = [];
arr = str.split(''); // [ 'H', 'e', 'l', 'l', 'o' ]

split.png

Array转String
let str = '';
let arr = [ 'H', 'e', 'l', 'l', 'o' ];
str = arr.join(); // Hello

join.png

slice()
*arrayObject.slice(start,end)
可从已有的数组中返回选定的元素(返回新数组)

slice.png

splice()
*arrayObject.splice(index,howmany,item1,.....,itemX)
splice() 方法向/从数组中添加/删除项目,然后返回被删除的项目(直接操作数组)
arrayObject.splice(index,howmany,item1,.....,itemX)

splice.png

sub()
stringObject.sub(index)
sub() 方法用于把字符串显示为下标

substr()
*stringObject.substr(start,length)
substr() 方法可在字符串中抽取从 start 下标开始的指定数目的字符。

substr.png

substring()
*stringObject.substring(start,stop)
substring() 方法用于提取字符串中介于两个指定下标之间的字符。
substring() 不接受负的参数。

substring.png

相关文章

  • [记录] 字符串、数组处理方法总结

    title: 字符串、数组处理方法总结date: 2017年9月6日 16:09:19tags: jscatego...

  • ES6 -- 数组

    扩展运算 用于数组处理为字符串 代替了apply方法,个人理解还是将数组处理看 合并数组,代替了cancat方法,...

  • js常用字符串处理方法

    与数组方法不同,字符串所有处理方法都不改变原字符串字符串转数组:split(str),match(re);返回布尔...

  • 2018-12-02

    数组 数组常用方法 通过标签获取元素 循环语句 数组去重 字符串处理的方法 字符串反转 计算器 定时器弹框

  • 字符串、定时器、数组

    字符串处理的方法 字符串反转 定时器弹框 定时器使用方法 定时器动画 数组 数组的常用方法 数组去重 作业 for...

  • 数组和字符串的处理方法

    数组 数组常用方法 数组去重 通过标签获取元素 字符串处理方法 字符串反转 定时器的基础用法 定时器动画 时钟 倒...

  • 数组 定时器

    数组: 面向对象的方式创建: 直接创建: 数组的常用方法: 数组去重: 字符串处理的方法: var a =char...

  • spring工具类最佳实践

    字符串处理函数 StringUtils方法分为三大类: 普通方法 格式化方法 字符串数组方法 常规方法 判定字符串...

  • js应用

    字符串处理方法 定时器弹框 数组去重

  • 前端数组

    数组的常用方法 面向对象的方式创建: 直接创建: 字符串处理的方法: 定时器: 数组去重:

网友评论

      本文标题:[记录] 字符串、数组处理方法总结

      本文链接:https://www.haomeiwen.com/subject/vpcvjxtx.html