Mercurial > js4py
changeset 207:29c7fe19aeb5
Mark inline code using duble backticks
| author | Radomir Dopieralski <radomir.dopieralski@allegro.pl> |
|---|---|
| date | Thu, 17 May 2012 11:24:48 +0200 |
| parents | a2fb6c95d156 |
| children | b1f5aa2daf53 |
| files | core-javascript/global.rst core-javascript/object-tree.rst core-javascript/simple-classes.rst |
| diffstat | 3 files changed, 16 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/core-javascript/global.rst Thu May 17 11:23:58 2012 +0200 +++ b/core-javascript/global.rst Thu May 17 11:24:48 2012 +0200 @@ -7,7 +7,7 @@ .. note:: - Douglas Crockford writes **JavaScript's global object ... is far and + Douglas Crockford writes **JavaScript's global object [...] is far and away the worst part of JavaScript's many bad parts.** @@ -83,7 +83,7 @@ js> array 1,2,3 -Let's try using *array.push* as a stand-alone function. +Let's try using ``array.push`` as a stand-alone function. .. code-block:: javascript @@ -96,7 +96,7 @@ The push function returns the length of the object it has just pushed to. So the value *3* above is a signal that all is not well. And indeed it is not. The original array is unchanged, and the global -object has an entry at 0. +object has an entry at *0*. .. code-block:: javascript
--- a/core-javascript/object-tree.rst Thu May 17 11:23:58 2012 +0200 +++ b/core-javascript/object-tree.rst Thu May 17 11:24:48 2012 +0200 @@ -8,7 +8,7 @@ value = obj.attr # Get the attr of 'a'. obj.attr = value # Set the attr of 'a'. -respectively **set** and **get** the "attr" attribute of the object +respectively **set** and **get** the ``attr`` attribute of the object ``obj``. Inheritance is where an object gets some its attributes from one or other more objects. JavaScript uses an object tree for inheritance. @@ -70,10 +70,10 @@ js> a.attr gotcha -If we give *root* a *attr* attribute then every other object, +If we give **root** a ``attr`` attribute then every other object, including those already created and those not yet created, also has a -*attr* attribute with the same value. (In practice it's better not to -change Object.prototpye.) +``attr`` attribute with the same value. (In practice it's better not to +change ``Object.prototpye``.) This applies arrays: @@ -102,7 +102,7 @@ incompatibilities. So try not to do this. -However, this up-the-tree lookup does not apply if *attr* is found +However, this up-the-tree lookup does not apply if ``attr`` is found earlier in the tree. We continue the previous example to show this, and the behaviour of set. @@ -119,13 +119,13 @@ ------ Any tree can be constructed from its root, together with a command -**create(parent)** that returns a new **child** of the given parent +``create(parent)`` that returns a new **child** of the given parent node. -In all but the most recent version of JavaScript the *create* function +In all but the most recent version of JavaScript the ``create`` function is not built in. However, it's easy to write one, once you know enough JavaScript. Here's how its done in the work folder's -library.js file. +``library.js`` file. .. literalinclude:: /core-javascript-work/library.js :language: javascript @@ -163,6 +163,6 @@ .. note:: - JavaScript uses an inheritance tree. By using *create*, we can + JavaScript uses an inheritance tree. By using ``create``, we can create any inheritance tree. All JavaScript objects are in this tree.
--- a/core-javascript/simple-classes.rst Thu May 17 11:23:58 2012 +0200 +++ b/core-javascript/simple-classes.rst Thu May 17 11:24:48 2012 +0200 @@ -7,15 +7,15 @@ along with a discussion of the consequences. For now our focus is on getting going with object-oriented -programming. The easiest way to do this is via create. +programming. The easiest way to do this is via ``create``. Definition ---------- Here's a factory function that creates classes. It returns a function -called *cls*, which in turn when called returns instances. At it's -heart is *create*, and also *apply* and *arguments*, which we've not +called ``cls``, which in turn when called returns instances. At it's +heart is ``create``, and also ``apply`` and ``arguments``, which we've not seen before). .. literalinclude:: /core-javascript-work/library.js @@ -37,7 +37,7 @@ Fruit example ------------- -Here's an example of the use of *SimpleClass*. There's a bug in it, +Here's an example of the use of ``SimpleClass``. There's a bug in it, and I've changed the test so it passes. Can you find the bug and fix the example?
