文字列操作

<SCRIPT Language="JavaScript"><!--

a=4;
b=2;
c="HELLO";
d="world";

document.write("<BR>c=",c);
document.write("<BR>d=",d);
document.write("<BR>文字の連結<BR>c+d=",c+d);
document.write("<BR>数値を文字として連結<BR>a+b=",""+a+b);


document.write("<BR>文字列の指定した場所だけを抜き出す d(0〜3)<BR>",d.substring(0,3));

document.write("<br>文字の長さ<br>",d,"の文字の長さは",d.length,"<BR>");

document.writeln("文字列中の指定の1文字を得る<br>","Cの2番目の文字は ",c.charAt(2));

document.writeln("<BR>大文字小文字変換<BR>");
document.writeln(" c を子文字に>> ", c.toLowerCase(),"<BR>");
document.writeln(" d を大文字に>> ", d.toUpperCase());


// --></SCRIPT>


実行結果
SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送