Mercurial > js4py
annotate core-javascript/exercise-1.rst @ 194:2f10061fec29 javascript-exercises
$ python py/remove_answers.py
| author | jf3243 |
|---|---|
| date | Mon, 21 Nov 2011 17:27:12 +0000 |
| parents | 58e4f484903f |
| children |
| rev | line source |
|---|---|
| 105 | 1 Exercise one |
| 2 ============ | |
| 3 | |
| 4 Here's some JavaScript code I found somewhere. I've changed the names | |
| 5 of everything to hide the origin of the code. But it's not something | |
| 6 I've made up. | |
| 7 | |
| 8 The exercise is | |
| 9 | |
| 10 #. Understand and describe what it does. | |
| 11 | |
| 12 #. Provide clearer code that does the same thing. | |
| 13 | |
| 14 #. Suggest a better way of going about things. | |
| 15 | |
|
145
58e4f484903f
Fix errors caused by mv in previous commit.
Jonathan Fine <jfine@pytex.org>
parents:
130
diff
changeset
|
16 .. literalinclude:: /core-javascript-work/exercise-1.js |
| 105 | 17 :language: javascript |
| 18 | |
| 19 | |
| 20 Hints | |
|
130
ff23e32bbe29
Sort out table of contents, and various minor changes.
jf3243
parents:
105
diff
changeset
|
21 ----- |
| 105 | 22 |
| 23 #. The code creates and calls an anonymous function, a bit like this. | |
| 24 | |
| 25 .. code-block:: javascript | |
| 26 | |
| 27 js> a = function(x){return x + 1}(2) | |
| 28 3 | |
| 29 | |
| 30 #. What happens if AAA is an object? | |
| 31 | |
| 32 #. What happens if AAA is undefined? | |
| 33 | |
| 34 #. For now, ignore the assignment to BBB.fff. What value does AAA | |
| 35 get? (The answer depends the initial value of AAA.) |
