Commits

Anonymous committed cd47db1

Make a start on immuatables.

  • Participants
  • Parent commits 0c7473e
  • Branches core-javascript

Comments (0)

Files changed (3)

core-javascript/immutables.rst

+Immutables
+==========
+
+First, a quick word about variables.  A value is an indentifier that
+holds a value.  In JavaScript every value has a type, but variables
+are not typed.  In other words, we can to any variable can hold any
+value.  Most dynamic language (such as Perl, Python and Ruby) are like
+this.
+
+Always declare variables with a var statement, because sometimes a
+missing var can cause a hard-to-find bug.  Experiments at the command
+line are the only exception to this rule.
+
+
+Strings
+-------
+
+Strings and numbers are the simple
+
+.. code-block:: javascript
+
+   js> s = 'Hello world.'
+   Hello world.
+
+We can add two strings together to produce a third string.
+
+.. code-block:: javascript
+
+   js> r = "I'm me. "
+   I'm me.
+   js> r + s
+   I'm me. Hello world.
+
+
+typeof
+------
+
+There's a built-in operator called 'typeof' that returns a string
+that, sort-of, gives the type of a value.
+
+.. code-block:: javascript
+
+  js> typeof(s)
+  string
+
+Because typeof is an operator (just as '+' is an operator) the
+parentheses are not needed, and many JavaScript programmers omit them.
+
+.. code-block:: javascript
+
+  js> typeof s
+  string
+
+Here we see that typeof produces (returns) a string.
+
+.. code-block:: javascript
+
+  js> typeof typeof s
+  string
+
+
+Numbers
+-------
+
+JavaScript numbers are platform and processor independent.  It uses
+IEE 754 to represent both integers and floats.
+
+.. code-block:: javascript
+
+   js> i = 42
+   42
+   js> typeof i
+   number
+
+
+Booleans
+--------
+
+JavaScript has keywords 'true' and 'false' whose values are always
+true and false respectively.
+
+.. code-block:: javascript
+
+   js> t = true
+   true
+   js> typeof b
+   boolean
+
+Logical comparisions also produce Booleans.
+
+.. code-block:: javascript
+
+   js> f = (1 > 2)
+   false
+   js> typeof f
+   boolean
+
+
+undefined and null
+------------------

core-javascript/index.rst

-.. Core JavaScript documentation master file, created by
-   sphinx-quickstart on Wed Oct 19 11:43:46 2011.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
 Welcome to Core JavaScript's documentation!
 ===========================================
 
 .. toctree::
    :maxdepth: 2
 
+   immutables
+   objects
+
 Indices and tables
 ==================
 
 * :ref:`genindex`
 * :ref:`modindex`
 * :ref:`search`
-

core-javascript/objects.rst

+Objects
+=======
+
+JavaScript has objects and is object-oriented, but in an unusual way
+(more on that later).