開発環境
- OS X Mavericks - Apple(OS)
- Emacs (CUI)、BBEdit - Bare Bones Software, Inc. (GUI) (Text Editor)
- Safari、Firefox + Firebug (Webプラウザ、プラグイン)
- JavaScript (プログラミング言語)
- jQuery (JavaScript Library)
『初めてのJavaScript 第2版』(シェリー・パワーズ著(Shelley Powers著)、武舎 広幸+武舎 るみ訳、オライリージャパン、2009年、ISBN978-4-87311-425-5) の4章(JavaScriptオブジェクト)、練習問第4-1, 4-2, 4-3, 4-4, 4-5.を解いてみる。
その他参考書籍
練習問第4-1, 4-2, 4-3, 4-4, 4-5.
コード(BBEdit)
var result = '', comma_separated_s = $('#t0').val(), a = comma_separated_s.split(','), str = 'The fun of functions is that they are functional.', replaced_str = str.replace(/\bfun\b/g, 'power'), d = new Date(), td = d.getDate(), n = 34.44, m = Math.floor(n), l = Math.ceil(n), i, max; result += '1. \n3番目の要素: ' + a[2] + '\n逆順に表示\n'; a.reverse(); result += a + '\n'; result += '2.\n置換前: ' + str + '\n置換後: ' + replaced_str + '\n'; result += '3.\n今日の日付: ' + td + '日\n'; d.setDate(td + 7); result += '1週間後の日付: ' + d.getDate() + '日\n'; result += '4.\n数: ' + n + '\n切り下げ: ' + m + '\n切り上げ: ' + l + '\n'; result += '5.\n'; str = 'apple.orange-strawberry,lemon-.lime'; replaced_str = str.replace(/[,.]/g, ','); a = replaced_str.split(','); for (i = 0, max = a.length; i < max; i += 1) { result += i + ': ' + a[i] + '\n'; } $('#pre0').text(result);
0 コメント:
コメントを投稿