changeset 208:b1f5aa2daf53

Use double backticks for inline code in gotcha quiz
author Radomir Dopieralski <radomir.dopieralski@allegro.pl>
date Thu, 17 May 2012 11:47:26 +0200
parents 29c7fe19aeb5
children f7362edfc7ce
files txt/gotcha.txt
diffstat 1 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/txt/gotcha.txt	Thu May 17 11:24:48 2012 +0200
+++ b/txt/gotcha.txt	Thu May 17 11:47:26 2012 +0200
@@ -4,7 +4,7 @@
    ...
 }
 ===
-Ordinary equality (==) can be surprising and so use **===** instead:
+Ordinary equality (``==``) can be surprising and so use ``===`` instead:
 
 .. code-block:: javascript
 
@@ -13,7 +13,7 @@
    '' == '0'                    // False.  Not transitive!
    undefined == null            // True
 
-I don't know of any situations where == is preferred.  To compare two
+I don't know of any situations where ``==`` is preferred.  To compare two
 values after conversion to string (respectively number) make it
 explicit by writing respectively:
 
@@ -31,7 +31,7 @@
 x == y                          // True or False?  When?
 ===
 
-In  **str + num** the *num* is silently converted to a string.
+In  **string + number** the *number* is silently converted to a string.
 
 .. code-block:: javascript
 
@@ -44,7 +44,7 @@
    15
 
  
-In  **num + str** the *num* is again silently converted to a string.
+In  **number + string** the *number* is again silently converted to a string.
 
 .. code-block:: javascript
 
@@ -87,7 +87,7 @@
   [7, 8, 9]
 ]
 ===
-In Python you'd get an TypeError from this code, as in:
+In Python you'd get an ``TypeError`` from this code, as in:
 
 .. code-block:: python
 
@@ -149,7 +149,7 @@
 b = tmp(1, 3);                   // What happens here?
 ===
 
-Python uses bound methods and so in Python *a.b* is a first class
+Python uses bound methods and so in Python ``a.b`` is a first class
 object.
 
 .. code-block:: python
@@ -206,14 +206,14 @@
        total = a + b
        return total / 2.0
 
-works because in Python *total* is recognised as being local to the
-function *average*.
+works because in Python ``total`` is recognised as being local to the
+function ``average``.
 
 In JavaScript variables are global unless explicitly declared as
 local.
 
 The sample code has a interesting side effect.  It assigns to the
-global variable *total*.
+global variable ``total``.
 
 .. code-block:: python
 
@@ -239,7 +239,7 @@
 ===
 
 This code, when run, gives all items the same number (namely number of
-items less one).  This is because only one value of *i* is captured.
+items less one).  This is because only one value of ``i`` is captured.
 (It is not because all items are getting the same onclick function.
 They are getting different functions, but with identical behaviour.)
 
@@ -260,7 +260,7 @@
    };
 
 When we do this, each onclick function captures its own copy of the
-argument *i* to *alert_n*.  (Closure capture function parameters in
+argument ``i`` to ``alert_n``.  (Closure capture function parameters in
 the same way as it captures function variables.)
 
 &&&
@@ -285,7 +285,7 @@
 Name = Charles
 ===
 
-The code above (provided the global object does not have a *name*
+The code above (provided the global object does not have a ``name``
 attribute) produces:
 
 .. code-block:: javascript
@@ -293,7 +293,7 @@
    js> fn(...)                     // Logging to go to console.
    Name = undefined
 
-When a JavaScript function executes, what *this* refers to depends on
+When a JavaScript function executes, what ``this`` refers to depends on
 the calling context.  In particular, in 
 
 .. code-block:: javascript
@@ -306,7 +306,7 @@
           return this.attribute;
        }
 
-the two occurences of *this* usually refer to completely different
+the two occurences of ``this`` usually refer to completely different
 objects.  To fix instead write:
 
 .. code-block:: javascript
@@ -320,11 +320,11 @@
           return that.attribute;
        }
 
-This works because *that* does not have the special role *this* has.
-In the returned function, *that* refers to the same object as *that*
-does in main part of *fn2*, which in turn refers to the same object as
-the *this* object in the body.
+This works because ``that`` does not have the special role ``this`` has.
+In the returned function, ``that`` refers to the same object as ``that``
+does in main part of ``fn2``, which in turn refers to the same object as
+the ``this`` object in the body.
 
-It is customary to write **that = that** to achieve this effect.
+It is customary to write ``that=that`` to achieve this effect.
 (Following the custom means no further explanation is required.)