
var str = “hello world”
document.write(str.length)输出字符串长度 12
给string 添加样式
<p>Big: " + txt.big() + "</p>
<p>Small: " + txt.small() + "</p>
<p>Bold: " + txt.bold() + "</p>
<p>Italic: " + txt.italics() + "</p>
<p>Blink: " + txt.blink() + " (does not work in IE)</p>
<p>Fixed: " + txt.fixed() + "</p>
<p>Strike: " + txt.strike() + "</p>
<p>Fontcolor: " + txt.fontcolor("Red") + "</p>
<p>Fontsize: " + txt.fontsize(16) + "</p>
<p>Lowercase: " + txt.toLowerCase() + "</p>
<p>Uppercase: " + txt.toUpperCase() + "</p>
<p>Subscript: " + txt.sub() + "</p>
<p>Superscript: " + txt.sup() + "</p>
<p>Link: " + txt.link("http://www.w3school.com.cn") + "</p>
返回字符串首次出现的位置
document.write(str.indexOf(“hello”)+“<br>”)
查找特定字符,若找到,则返回该字符
document.write(str.match("world") + "<br/>”)
替换字符
var str="Visit Microsoft!"
document.write(str.replace(/Microsoft/,"W3School"))