Learning JavaScript: part I

Recently I spoke with several individuals wanting to build web applications. First I describe what a web application is, describe the front tier of a web application, and focus on JavaScript’s role for the front tier.

Web Applications

Web applications comprise of three tiers: front end, middle tier, and back end. The front end is required for writing interactive applications; the middle tier and back ends are necessary for sharing information between computers using the Internet. For example, I have a completely front-tier app for Kinematic Templates (cursor manipulation drawing software): it does not need the Internet to run. Middle tiers and back ends are required for websites that handle data from multiple people. One approach for building a middle tier is through REST APIs (see other posts). RailsBridge (a bridge for learning Rails) provides excellent resources for building a Ruby on Rails back end.

Front Tier MVC

Let me focus on the front tier in this post. The front tier is composed of a model, view, and controller. The model is represented in HTML, a markup language that describes the content of a web page. A person can see HTML in a web browser by choosing the “View Source” option. The view describes how the page should appear, which is provided using Cascading style sheets (CSS). If omitted, a default CSS is presented in the web browser. Many web pages today, however, mash the model and view  together, but they could and should be separated. Finally, the controller  affects the behaviour of a web page. It allows a web page to respond to clicks, typing, and other events without reloading a web page. The only language supported natively in web browsers for the controller is JavaScript.

JavaScript

JavaScript is a programming language that can modify a web page’s behaviour. But, it is more powerful than just for web pages. It can run a middle tier and back end using Node.js, but that is a topic for another post. In this post, we are going to cover some basic resources for learning JavaScript. We need to know JavaScript the language and then how to modify a web page using JavaScript.

JavaScript: The Language

Many resources are available on the web for learning JavaScript. Many of these resources, however, are outdated as the JavaScript language has evolved. The most recent version of JavaScript is 1.8.5 in July 2010. So when looking for online resources, a reader has to make sure they are reading the most recent edition. I suggest the following book from my own experience:

JavaScript Programmer’s Reference
Alexei White
Wrox Press, 2009 (1032 pages)
ISBN:9780470344729

I found the following chapters useful (below). I omit half the book from this reading list: many new JavaScript libraries are now available, e.g., jQuery, underscore.js, and backbone.js. They provide design patterns for using JavaScript in a web browser. I’ll blog about JavaScript in a web browser in another post.

  • Chapter 1            –              Introduction to JavaScript
  •  Chapter 2            –              JavaScript in the Browser
  •  Chapter 3            –              JavaScript Basics
  •  Chapter 4            –              Expressions, Operators, and Statements
  •  Chapter 5            –              Functions
  •  Chapter 6            –              The Global and Object Objects
  •  Chapter 7            –              The String and RegExp Objects
  •  Chapter 8            –              The Boolean, Number, and Math objects
  •  Chapter 9            –              The Array and Date Objects
  •  Chapter 10          –              Object Oriented Development
  •  Appendix A          –              Core JavaScript Language
  •  Appendix B          –              JavaScript Global Objects
  •  Appendix C          –              JavaScript Global Properties
  •  Appendix D          –              JavaScript Global Functions
  •  Appendix E          –              Reserved and Special Words