Basic JavaScript*

This is a computer translation of the original content. It is provided for general information only and should not be relied upon as complete or accurate.

I was in high school when we got our first "home computer". At the time there were quite a variety of home computers available, with different operating systems, different hardware and different features. One thing they all had in common, though, was 'Basic'. Pretty much every computer came with the ability to write and execute Basic programs.

Computer magazines often included printed code listings that you could type in to run programs, be they games or more utilitarian apps. You didn't need to buy a compiler, or any development tools (though some were available). You could just type stuff in and run it (or debug it). Once you had a computer, there were few barriers to developing your own code.

Of course, while they all ran Basic, they didn't all run the same Basic. There were a lot of slightly incompatible varieties of that too, but programs were small and after fooling around with a few programs a reasonably motivated teenager could generally figure out how to make a program work on a given system without too much trouble. It was a de facto, if loose, standard that allowed for a burst of programming activity, which for many began the long journey to a lifetime of fiddling with computers and shaping them for an unexplored future. Basic enabled kids like me to program real computers in ways that were not available before.

Fast forward 10 or 15 years and the World Wide Web burst on the scene, adding a more fully connected aspect to the home computer. Now it was easy for everyone to have a presence on the web, and thanks to HTML, lots of people were comfortable tweaking or even creating web pages with a facility undreamed of just a few years previous. Of course, HTML varied a bit depending on your platform, but a roughly universal, if imperfect, standard enabled another explosion of possibilities that today we take for granted.

Everyone with a browser (generally available for free if you didn't already have one) and a text editor could build their own web pages (love those blink tags) and every webpage offered examples to learn from. But HTML isn't a programming language in the sense that Basic or Fortran is. It allowed organizing and formatting of static data, but you couldn't build a Turing Machine with it. To deal with that limitatio n, Javascript was introduced and before long Javascript execution became a necessity for every browser. And as with HTML, everyone who had a browser and a text editor (essentially everyone with a computer) ha d the ability to develop Javascript code.

Javascript is not a perfect language. Javascript has been plagued by different behavior on different platforms, but it has some very important features. It is ubiquitous on the web. Every browser supports it. While it is lacking many features that programmers like from other languages, it is simple and flexible. For good or bad, Javascript has become perhaps the most universally available programming language in the known universe. Just like Basic.

So, if you've never tried it before, now's your chance. Right now, in your browser, bring up your "Javascript Console". Every browser has one, it's just a matter of finding the right key combination or menu items. This link may help. In Chrome it's Control-Shift-J (or Alt-Cmd-J on the Mac). You don't need to navigate to a new page, or create a new tab or anything.

Now you should see a prompt with a "Greater Than" sign. Type in "console.log('Hello World.')" and it should respond with "Hello World.":

> console.log("Hello World.")
Hello World.
undefined
>

In the console, you'll see that it also prints out "undefined" which just means that the function you called (console.log) didn't return anything. Nothing to worry about in this case. Now type in "alert('Hello Universe.')" and you should get a dialog popping up that says "Hello Universe.":

> alert("Hello Universe.")
undefined
>

Just like Basic, it's easy to get started. What's better is that, though you don't need any other tools to get started, there are lots of freely available tools (debuggers, editors, analyzers) as you find them useful. Some of them are even there in your browser.