js字符串函数之split()join()
split方法用于把一个字符串切割成字符串数组,与join相反
一个参数表示以该参数为切割点,
var str="silence's world";
console.log(str.split(" "));// ["silence's", "world"]
console.log(str.split("'"));// ["silence", "s world"]
console.log(str.split(""));//["s", "i", "l", "e", "n", "c", "e", "'", "s", " ", "w", "o", "r", "l", "d"]
//两个参数时,后一个参数表示长度
console.log(str.split("'",1));// ["silence"]
console.log(str.split("",5));// ["s", "i", "l", "e", "n"]
join方法用于将数组连接成字符串
var arr=["s","i","l","e","n","c","e"]
console.log(arr.join(","));//s,i,l,e,n,c,e
console.log(arr.join(""));//silence
console.log(arr.join("."));//s.i.l.e.n.c.e
console.log(arr.join("|"));//s|i|l|e|n|c|e
js字符串函数之split()join()的更多相关文章
- js字符串函数(split、join、indexOf、substring)
1,函数:split()功能:使用一个指定的分隔符把一个字符串分割存储到数组示例: str="jpg|bmp|gif|ico|png";arr= str .split(" ...
- js字符串函数
JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...
- 【repost】js字符串函数
JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...
- js字符串函数 [http://www.cnblogs.com/qfb620/archive/2011/07/28/2119799.html]
JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...
- 2018-06-20 js字符串函数
str.length -> 字符串长度; str.indexOf() -> 从左边查找字符串中某字符的位置: str.lastIndexOf -> 从右边查找字符串中某字符的位置: ...
- js字符串函数之substring() substr()
substring 方法用于提取字符串中介于两个指定下标之间的字符 substring(start,end) 开始和结束的位置,从零开始的索引 参数 描述start 必需.一个非负的整 ...
- js字符串函数之indexOf()
indexOf 返回字符串中指定字符首次出现的位置 var str="hello, I am Miss bean!"; str.indexOf("l")//结果 ...
- js执行js字符串函数的方法
<script> var jsText = 'return function(){alert(1+1)}' var jscode = new Function(jsText)(); jsc ...
- js课程 3-10 js中字符串函数数组函数和其它语言中对应函数的区别和联系是什么
js课程 3-10 js中字符串函数数组函数和其它语言中对应函数的区别和联系是什么 一.总结 一句话总结:js中是对象点方法的形式,这些方法都是对象的方法,而在php.java中却不是这样. 1.j ...
随机推荐
- 【leetcode❤python】 234. Palindrome Linked List
#-*- coding: UTF-8 -*-class Solution(object): def isPalindrome(self, head): ""&q ...
- CodeForces 219B Special Offer! Super Price 999 Bourles!
Special Offer! Super Price 999 Bourles! Time Limit:1000MS Memory Limit:262144KB 64bit IO For ...
- background:linear-gradient()
文章一 http://www.runoob.com/css3/css3-gradients.html 文章二:http://www.w3cplus.com/content/css3-gradien ...
- Setting Margin Properties in code
http://stackoverflow.com/questions/1003772/setting-margin-properties-in-code The problem is that Mar ...
- 9.Parameters
1.Optional and Named Parameters calls these methods can optionally not specify some of the arguments ...
- Native SQL
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- Thinkphp 3.2 添加 验证码 如何添加。
1,在home模块indexController.class.php中,加入以下代码 <?php namespace Home\Controller; use Think\Controller; ...
- python中self,cls
cls主要用在类方法定义,而self则是实例方法. self, cls 不是关键字,完全可以使用自己写的任意变量代替实现一样的效果. 普通的实例方法,第一个参数需要是self,它表示一个具体的实例本身 ...
- hdu 5476 Explore Track of Point(2015上海网络赛)
题目链接:hdu 5476 今天和队友们搞出3道水题后就一直卡在这儿了,唉,真惨啊……看着被一名一名地挤出晋级名次,确实很不好受,这道恶心的几何题被我们3个搞了3.4个小时,我想到一半时发现样例输出是 ...
- The new day of my blog
今天开始了我的博客建造之旅,作为一个ACMer(虽说是弱校的),我也想象其他人一样把自己的题解和心得记录下来,一来可以和大家分享一下,二来也可以留给将来的自己作回顾,希望众大神能够给以指导指导,让我这 ...