【実行画面】
<script type="text/javascript">
<!--
var a = "abc";
var b = "XYZ";
var w = a + b;
document.write("a:", a, " b:", b, " w=a+b:", w, "<br>");
str = "a:" + a + " b:" + b + " w:" + w + "<br>";
document.write(str);
// -->
</script>
|
【実行画面】
<script type="text/javascript">
<!--
var a = "123";
var b = 45;
v = a + b;
w = parseInt(a) + b;
x = a + b.toString();
document.write('v"a+b":', v, " : w'parseInt(a)+b':", w, ' : x"a+b.toString()":', x, "<br>");
z = parseFloat("3.14") + 1.23;
document.write("z:", z, "<br>");
// -->
</script>
|
【実行画面】
<!--
str = "ABC前田XYZ";
document.write("[" + str.charAt(1) + "]");
document.write("[" + str.charAt(3) + "]");
document.write("[" + str.charAt(6) + "]");
document.write("<br>", str.substring(2,6));
document.write("<br>", str.substr(2,6));
// -->
|
【実行画面】
<script type="text/javascript">
<!--
a = "23:59:59".split(":");
document.write(a[0] + "時" + a[1] + "分" + a[2] + "秒");
// -->
</script>
|
![]()