Browse files

Better close?

  • Loading branch information...
1 parent b2b5c4a commit f3e54b6ea10d9053514043376db8be8b8f4eb85a @raganwald raganwald committed Feb 4, 2013
Showing with 10 additions and 2 deletions.
  1. +10 −2 2013/02/
12 2013/02/
@@ -123,7 +123,15 @@ A constructor in JavaScript is any function. A prototype in JavaScript is any ob
### so why do some people say that javascript has "classes" for some definition of "class?"
-Because if you are disciplined and assign only functions to a prototype object, and if those functions use `this` to work with an instance, and if you set up a prototype chain when you want inheritance, you have something that works just like a simple class-based system.
+Because, **if**:
+1. You use a function as a constructor, and;
+2. You use a prototype for defining instance methods, and;
+3. The prototype is used strictly for defining the instance methods and nothing else;
+You will have something that works just like a simple class-based system, with the constructor function and its prototype acting as the "class."
But if you want more, you have a flexible system that does allow you to do more. It's up to you.
@@ -144,4 +152,4 @@ My recent work:
(Spot a bug or a spelling mistake? This is a Github repo, fork it and send me a pull request!)
-[Reg Braithwaite]( | [@raganwald](
+[Reg Braithwaite]( | [@raganwald](

0 comments on commit f3e54b6

Please sign in to comment.