??? ??? ??
??? ??? ??
(1) ???? ??
???? ??? ???? ??? ??? ??? ????. ??? ?? ??? ??? ??? ?? ?:
var test_var = "I love You!"; document.write(test_var.length);
? ??? ??? ??? ??? ????? ??? "11"? ?????.
??? ??? ????? ??:
??? ??? toUpperCase() ???? ???? ??? ???? ???? ??:
var mystr="Hello world!"; var mynum=mystr.toUpperCase();
? ?? ????? mynum? ?? ??? ????. HELLO WORLD!
(2)String method
String ???? ??? ????. 19?? ?? ??? ? ?? ???? ??? ??, ?? ??, ?? ??, ?? ?? ? ???? ??? ?? ??? ?????.
charAt(n) : ???? n?? ?? ??? ?????. (0?? ??)
charCodeAt(n): ???? n?? ??? ?? ?? ??? ASCII ??? ?????.
indexOf() : ???: string_1.indexOf(string_2,n); ??? string_1? n?? ???? ??? ????, string_2? ????, ?? ?? ?? ?? ??? ?????. ?? -1? ???? n? ?? ? ? ??? ????? 0?? ???? ??? ?????.
lastIndexOf(): indexOf()? ????? ??? ?????.
split('separator') : ??? ?? ??? ?? ???? ???? ??? ?????. ?: '1&2&345&678'.split('&'); 1,2,345,678.
substring(n,m) : n ???? m ???? ?? ???? ?? ???? ?????.
substr(n,x) : ?? n?? ???? ??? x? ?? ???? ?? ???? ?????.
toLowerCase(): ?? ???? ???? ?? ???? ??? ???? ?????.
toUpperCase() : ?? ???? ?? ???? ???? ??? ???? ?????.
??? ?? ??
<html> <body> <script type="text/javascript"> var txt="Hello World!" document.write(txt.length) </script> </body> </html>
???? ??? ??
<html> <body> <script type="text/javascript"> var txt="Hello World!" document.write("<p>Big: " + txt.big() + "</p>") document.write("<p>Small: " + txt.small() + "</p>") document.write("<p>Bold: " + txt.bold() + "</p>") document.write("<p>Italic: " + txt.italics() + "</p>") document.write("<p>Blink: " + txt.blink() + " (does not work in IE)</p>") document.write("<p>Fixed: " + txt.fixed() + "</p>") document.write("<p>Strike: " + txt.strike() + "</p>") document.write("<p>Fontcolor: " + txt.fontcolor("Red") + "</p>") document.write("<p>Fontsize: " + txt.fontsize(16) + "</p>") document.write("<p>Lowercase: " + txt.toLowerCase() + "</p>") document.write("<p>Uppercase: " + txt.toUpperCase() + "</p>") document.write("<p>Subscript: " + txt.sub() + "</p>") document.write("<p>Superscript: " + txt.sup() + "</p>") document.write("<p>Link: " + txt.link("http://www.miracleart.cn") + "</p>") </script> </body> </html>