summaryrefslogtreecommitdiffhomepage
path: root/javascript.html.markdown
diff options
context:
space:
mode:
authorAdam Brenecki <adam@brenecki.id.au>2013-06-30 17:48:50 +0930
committerAdam Brenecki <adam@brenecki.id.au>2013-06-30 17:48:50 +0930
commitc2d5429472fb945bec81b42789dc0fd6161df433 (patch)
tree13a718e851060fbbf1b22b8b79a03b931c0c4afe /javascript.html.markdown
parent7c4bd7120c36b525c126e08df0b22c25830ba4e0 (diff)
Tidy up section on variables, arrays and objects
Diffstat (limited to 'javascript.html.markdown')
-rw-r--r--javascript.html.markdown13
1 files changed, 8 insertions, 5 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown
index 6234aebc..cb866886 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -108,13 +108,16 @@ undefined // used to indicate a value that hasn't been set yet
// Variables are declared with the var keyword. Javascript is dynamically typed,
// so you don't need to specify type. Assignment uses a single = character.
-var some_var = 5
+var someVar = 5
// if you leave the var keyword off, you won't get an error...
-some_other_var = 10
+someOtherVar = 10
-// but your variable will always end up with the global scope, even if it wasn't
-// defined there, so don't do it.
+// ...but your variable will be created in the global scope, not in the scope
+// you defined it in.
+
+// Variables declared without being assigned to are set to undefined.
+var someThirdVar // = undefined
// Arrays are ordered lists of values, of any type.
["Hello", 45, true]
@@ -133,7 +136,7 @@ myObj["my other key"] // = 4
// ... or using the dot syntax, provided the key is a valid identifier.
myObj.myKey // = "myValue"
-// Objects are mutable, values can be changed and new keys added.
+// Objects are mutable; values can be changed and new keys added.
myObj.myThirdKey = true
/***********