获得字符串长度  

<script type="text/javascript">
	var str = "abc";
	alert(str.length);
</script>

 

获得Unicode编码所表示的字符串  

<script type="text/javascript">
	var str = String.fromCharCode(24046,24322);//结果是“差异”
	alert(str);
</script>

 

获得字符所对应的Unicode编码  

<script type="text/javascript">
	var str = "不明白";
	alert(str.charCodeAt(2));
</script>

 

获得字符串指定位置的字符  

<script type="text/javascript">
	var str = "abcdefg";
	alert(str.charAt(5));//结果是"f"
</script>

 

连接多个字符串,得到新的字符串  

<script type="text/javascript">
	var str = "123";
	alert(str.concat("abc","456","xyz","789"));
</script>

 

查找某字符串首次出现的位置  

<script type="text/javascript">
	var str = "123456789abc";
	alert(str.indexOf("bc"));
</script>

 

查找某字符串最后一次出现的位置  

<script type="text/javascript">
	var str = "1234bc56789abc";
	alert(str.lastIndexOf("bc"));
</script>

 

判断字符串相等关系  

<script type="text/javascript">
	if(0 == "abc".localeCompare("bcd"))
	{
		alert("same");
	}
	else
	{
		alert("different");		
	}
</script>

 

分割字符串,返回数组  

<script type="text/javascript">
	var str = "a;b;c;d;e";

	var strArray = str.split(";");
	alert(strArray);
	
	var strArray2 = str.split(";",3);
	alert(strArray2);
</script>

 

获取子字符串  

<script type="text/javascript">
	var str = "a;b;c;d;e";
	alert(str.substring(2,6));
</script>

 

转换成小写  

<script type="text/javascript">
	var str = "abCDe";
	alert(str.toLowerCase());
</script>

 

转换成大写  

<script type="text/javascript">
	var str = "abCDe";
	alert(str.toUpperCase());
</script>