标签:efi 开头 prot prototype with 对象 起点 组成 不能
String.formCharCode("55"); >>>>>>"7"
var str="hello world"; str.charAt(0);
var str="hello world"; str.charCodeAt(0); >>>>>104(Number);
var str="hello", str2="world"; var str3=str.concat(str2); >>>>>"helloworld";
var str="hello world"; str.endsWith("d"); >>>>>true
var str="hello world"; str.includes("he"); >>>>>>true str.includes("hl"); >>>>>>false
str="hello world"; str.indexOf("l"); >>>>>>2 str.indexOf("z"); >>>>>>-1
var str="hello world"; str.lastIndexOf("l"); >>>>>>9 str.laseIndexOf("ll"); >>>>>>2
var str="hello world"; str.match(‘hello‘); >>>>>>"hello" str.match(/l+/g); >>>>>>[‘ll‘,‘l‘] var str="<input value={wwwww} type={222222} />"; var arr=str.match(/{(\w+)}/); >>>>>>[‘{wwwww}‘,‘wwwww‘]; for(var i in arr)console.log(i); >>>>>>0,1,index,input
var str="lili"; str.repeat(2); >>>>>>"lililili";
var str="hello world!"; str.replace("l",‘o‘); >>>>>>"heolo world!"; str.replace(/l/g,"o"); >>>>>>"heooo worod"; str.replace(/l/g,function(){ return "o"; }) >>>>>>"heooo worod";
var str="123456789.abcde"; console.log(str.search("."));//0 因为正则.匹配\n以外任意字符 console.log(str.indexOf("."));//9 只匹配字符串. console.log(str.search("\\."));//9 console.log(str.indexOf("\\."));//-1 匹配\. 所以不存在 console.log(str.search(/\./)); //9 正则匹配后.字符 console.log(str.indexOf(/\./)); //-1 相当于匹配‘/\./‘ 所以不存在
var str="hello world"; str.slice(0); >>>>>>"hello world" str.slice(0,-1); >>>>>>"hello worl" str.slice(2,1); >>>>>>""
var str="hello world"; str.split(""); >>>>>>["h","e","l","l","o"," ","w","o","r","l","d"] str.split(/\s+/,1); >>>>>>["hello"]
var str="hello world"; str.substring(0,5); >>>>>>"hello"; str.substring(0); >>>>>>"hello world";
var str="hello world"; str.sbustr(0,5); >>>>>>"hello" str.substr(-1,5); >>>>>>"world" str.substr(0); >>>>>>"hello world"
var str="hello world"; str.startsWith("hello"); >>>>>>true;
javaScript的String.prototype的所有方法
标签:efi 开头 prot prototype with 对象 起点 组成 不能
原文地址:http://www.cnblogs.com/chairs/p/6985597.html