Commits

Anonymous committed 7b81c64

Make a start on global.rst (more work required).

Comments (0)

Files changed (3)

core-javascript/conf.py

 # If false, no module index is generated.
 #latex_domain_indices = True
 
+# Added at the end of the \documentclass[options]{...}.
+# 'english' added to keep Babel quiet.
+# http://groups.google.com/group/sphinx-dev/browse_thread/thread/ee301b14175ad5bb/c06c6600192a17da
+latex_elements = {
+    'classoptions': ',openany,english',
+}
 
 # -- Options for manual page output --------------------------------------------
 

core-javascript/global.rst

+The global object
+=================
+
+JavaScript has a global object.  Douglas Crockford write "JavaScripts
+global object ... is far and away the worst part of JavaScript's many
+bad parts."
+
+
+Getting global
+---------------
+
+.. code-block:: javascript
+
+
+   js>
+   js>
+   js> return_this = function(){return this;}
+
+   function () {
+       return this;
+   }
+
+   js> global = return_this()
+   [object global]
+   js>
+   js> s = 'Hello world.'
+   Hello world.
+   js> global.s
+   Hello world.
+   js> global.i = 42
+   42
+   js> i
+   42
+   js>
+   js> pollute = function(n){ i = n; };
+
+   function (n) {
+       i = n;
+   }
+
+   js> i
+   42
+   js> pollute(13)
+   js> i
+   13
+   js>
+   js>
+   js> array = []
+
+   js> array.push(1, 2, 3)
+   3
+   js> array
+   1,2,3
+   js> p = array.push
+   function push() { [native code for Array.push, arity=1] }
+
+   js>
+   js> p(4, 5, 6)
+   3
+   js> array
+   1,2,3
+   js>
+   js> global[0]
+   4
+   js>

core-javascript/index.rst

    equality
    objects
    object-tree
+   global
 
 Indices and tables
 ==================