Commits

jf3243  committed bc9be47

Done with immutables for now.

  • Participants
  • Parent commits cd47db1
  • Branches core-javascript

Comments (0)

Files changed (1)

File core-javascript/immutables.rst

 
 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.
+are not typed.  In other words, 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.
 
+We can change an array or a 'dictionary'.  Immutable values are values
+that can't be changed.  We can't change, for example, the third
+character in a string.
+
 
 Strings
 -------
 
-Strings and numbers are the simple
+Strings literals are delimited by single or double quote marks, with
+special characters escaped.  There's no difference between the two
+forms (except in single quote you don't have to escape double quote,
+and vice versa.)  Generally, I prefer the single quote form as it's
+less busy on the eye and slightly easier to type.
 
 .. code-block:: javascript
 
 
 undefined and null
 ------------------
+
+JavaScript has *two* values that represent None.  Later, we'll see
+why, and which to use when.  For now we'll simply note that they are
+different, because their types are different.
+
+.. code-block:: javascript
+
+   js> typeof undefined
+   undefined
+   js> typeof null
+   object
+
+
+Gotchas
+-------
+
+.. code-block:: javascript
+
+   js> s = 'Hello world.'
+   Hello world.
+   js> s.lang = 'en'
+   en
+   js> s.lang === undefined
+   true