Kamimura's blog
プログラミング(Python、Perl、C、Go、JavaScript)、数学、読書…
ほしい物リスト
2010年6月23日水曜日
プログラミング学習の記録 230.1 はじめてのプログラミングとJavaScriptの基礎の第5章(演算)の練習問題5.4, 5.5
開発環境:Microsoft Windows 7 Home Premium(OS)+Internet Explorer 8(ブラウザの開発者ツール)
"はじめてのプログラミングとJavaScript"のp.129、第5章(演算)の練習問題5.4, 5.5を解いてみる。
5.4
var num = 10; var str = "String" var bln = true; var date = new Date(); function Insert(data, type) { var d0 = document.getElementById("d0"); var p = document.createElement("p"); text = document.createTextNode(data + " Type: " + type); p.appendChild(text); d0.appendChild(p); } Insert(num, typeof num); Insert(str, typeof str); Insert(bln, typeof bln); Insert(date, typeof date);
5.5
var num = 1; while (num <= 128) { document.write(num + " "); num <<= 1; } document.write("
"); while (1 <= num) { document.write(num + " "); num >>= 1; }
0 コメント:
コメントを投稿
次の投稿
前の投稿
ホーム
コメントの投稿(Atom)
0 コメント:
コメントを投稿