Mercurial > js4py
diff core-javascript/object-tree.rst @ 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 | 45e7d5e8fa97 |
| children |
line wrap: on
line diff
--- 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.
