Skip to content
Browse files

Move object code to own file

  • Loading branch information...
1 parent 8e8a690 commit 60147cc997412decbc853bc55e837a433c7a9dbd @creationix committed
Showing with 10 additions and 12 deletions.
  1. +9 −0 object1.js
  2. +1 −12 slides.html
View
9 object1.js
@@ -0,0 +1,9 @@
+var obj = {}; // Create a new object
+obj.name = "Tim"; // Give it a name
+obj.race = "human"; // It is human right?
+obj.hitPoints = 42; // 42 has a nice ring to it.
+obj.getDescription = function () {
+ return this.name + " the " + this.race + " has " + this.hitPoints + " hitpoints.";
+};
+
+var description = obj.getDescription();
View
13 slides.html
@@ -170,18 +170,7 @@ <h1 style="margin-top:100px;">How Firm is Your<br/>
In any node program there is the concept of state. It's useful for remembering where you were when an event comes in.
</p>
<p>JavaScript has objects that are used for storing internal state in named properties accessible via <code>this</code>.</p>
- <pre>
-var obj = {}; // Create a new object
-obj.name = "Tim"; // Give it a name
-obj.race = "human"; // It is human right?
-obj.hitPoints = 42; // 42 has a nice ring to it.
-obj.getDescription = function () {
- return this.name + " the " + this.race + " has " + this.hitPoints + " hitpoints.";
-};
-
-var description = obj.getDescription();
-</pre>
-
+ <script src="http://snippets.c9.io/github.com/creationix/utahjs-2012/object1.js" defer="defer"></script>
</article>
<article>
<p>Here is the same example using the common constructor + prototype method.</p>

0 comments on commit 60147cc

Please sign in to comment.
Something went wrong with that request. Please try again.