目次 |
---|
・文字列から空白をカット ・ソース ・文字列の宣言 |
<html> <head> <title></title> </head> <body> <scripttype="text/javascript"> function b(){ var a = "t e s t"; alert(a.replace(/ /g,"")); } </script> <buttononclick="a()">ボタン</button> </body> </html>
var a = new String("test1");
<script type="text/javascript"> <!-- var a = "test1"; document.write("長さ:" + a.length + "<br />"); document.write("2文字目から4文字目を取得:" + a.slice(2,5) + "<br />"); --> </script>