|
116
|
1 Getting started
|
|
|
2 ===============
|
|
|
3
|
|
|
4 What you need
|
|
|
5 -------------
|
|
|
6
|
|
|
7 You'll need on your machine
|
|
|
8
|
|
|
9 #. A JavaScript interpreter which provides a command line
|
|
|
10
|
|
|
11 #. An editor on your machine.
|
|
|
12
|
|
|
13 You'll also to download and unzip the course :download:`work folder
|
|
|
14 </core-javascript-work.zip>`.
|
|
|
15
|
|
|
16
|
|
|
17 Windows and Linux
|
|
|
18 -----------------
|
|
|
19
|
|
|
20 For Windows the easiest thing to do is to `download the JSDB
|
|
|
21 interpreter <http://www.jsdb.org/download.html>`_, and use notepad (or
|
|
|
22 some other editor).
|
|
|
23
|
|
|
24 For Linux you and install Rhino and use your favourite editor.
|
|
|
25
|
|
|
26 .. code-block:: sh
|
|
|
27
|
|
|
28 $ sudo apt-get install rhino
|
|
|
29
|
|
|
30
|
|
|
31 Are you ready?
|
|
|
32 --------------
|
|
|
33
|
|
|
34 You'll want to be able to run the JavaScript interpreter from the
|
|
|
35 command line when in the work folder. This will be automatic (via the
|
|
|
36 PATH) with Linux and Rhino. For Windows the easiest thing to do is to
|
|
|
37 place the jsdb.exe file in the work folder.
|
|
|
38
|
|
|
39 When you're ready type *js* at a command prompt. This starts the
|
|
|
40 interpreter and gives you a *js>* prompt. You'll get something like
|
|
|
41 this.
|
|
|
42
|
|
|
43 .. code-block:: javascript
|
|
|
44
|
|
|
45 core-javascript-work$ js
|
|
|
46 Rhino 1.7 release 2 2010 01 20
|
|
|
47 js>
|
|
|
48
|
|
|
49 Now type the command as below at the JavaScript prompt (with Return at the end of
|
|
|
50 each line) and you'll get responses as below.
|
|
|
51
|
|
|
52
|
|
|
53 .. code-block:: javascript
|
|
|
54
|
|
|
55 js> a = '0'
|
|
|
56 0
|
|
|
57 js> b = 0
|
|
|
58 0
|
|
|
59 js> c = ''
|
|
|
60
|
|
|
61 js> a == b
|
|
|
62 true
|
|
|
63 js> b == c
|
|
|
64 true
|
|
|
65 js> a == c
|
|
|
66 false
|
|
|
67
|
|
|
68
|
|
|
69 You might be surprised by the last response from the interpreter, but
|
|
|
70 every JavaScript interpreter does this.
|
|
|
71
|
|
|
72
|
|
|
73 Yes, you're ready
|
|
|
74 -----------------
|
|
|
75
|
|
|
76 To exit the interpreter use Ctrl-C or Ctrl-D.
|