Skip to Main Content
Eloquent JavaScript
book

Eloquent JavaScript

by Marijn Haverbeke
January 2011
Intermediate to advanced content levelIntermediate to advanced
224 pages
5h 43m
English
No Starch Press
Content preview from Eloquent JavaScript

Trying Programs

When you want to run the code shown in this book and play with it, one possibility is to go to http://eloquentjavascript.net/ and use the tools provided there.

Another approach is to simply create an HTML file containing the program and load it in your browser. For example, you could create a file called test.html with the following content:

<html><body><script type="text/javascript">

var total = 0, count = 1;
while (count <= 10) {
  total += count;
  count += 1;
}
document.write(total);

</script></body></html>

Later chapters will tell you a little more about HTML and the way a browser interprets it. Note that the operation print in the example has been replaced with document.write. We will see how to create the print function in Chapter 10 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Eloquent JavaScript, 3rd Edition

Eloquent JavaScript, 3rd Edition

Marijn Haverbeke
Learn JavaScript

Learn JavaScript

Shaun Wassell

Publisher Resources

ISBN: 9781593272821Errata