開発環境
- macOS High Sierra - Apple
- Emacs (Text Editor)
- JavaScript (プログラミング言語)
- Safari(Web browser)
Eloquent JavaScript, 2nd Ed.: A Modern Introduction to Programming(Marijn Haverbeke 著、No Starch Press)のPart 2(Browser)、Chapter 18(Forms and Form Fields)、Exercises(A JavaScript Workbench)を取り組んでみる。
Exercises(A JavaScript Workbench)
HTML5
<pre id="output0"></pre> <textarea id="textarea0">return 'Hello, World!'</textarea> <br> <button id="run0">run</button> <script src="sample1.js"></script>
JavaScript
let pre0 = document.querySelector('#output0'), text0 = document.querySelector('#textarea0'), btn0 = document.querySelector('#run0'), p = (text) => pre0.textContent = text; btn0.onclick = () => { try { let f = new Function('', text0.value); p(f()); } catch (e) { p(e); } };
0 コメント:
コメントを投稿