Skip to content

Commit

Permalink
Merge pull request #38 from jonelf/patch-1
Browse files Browse the repository at this point in the history
Update 2013/02/prototypes.md
  • Loading branch information
raganwald committed Feb 4, 2013
2 parents 1e324f7 + 34c79c4 commit 9f32485
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 2013/02/prototypes.md
Expand Up @@ -75,7 +75,7 @@ class Queue
end
```

There is special sntax for defining a class, and special syntax for defining the behaviour of instances. There are different ways of defining the way new instances are created in classist languages. Ruby uses a "magic method" called `initialize`. Now let's look at JavaScript.
There is special syntax for defining a class, and special syntax for defining the behaviour of instances. There are different ways of defining the way new instances are created in classist languages. Ruby uses a "magic method" called `initialize`. Now let's look at JavaScript.

### javascript has constructors and prototypes

Expand All @@ -100,7 +100,7 @@ As you can see, the `square` function will act as a constructor if you call it w

That's different from a true classical language, where the class is a special kind of object that creates new instances.

How does JavaScript define the bahaviour of instances? JavaScript doesn't have a special syntax or special kind of object for that, it has "prototypes." Prototypes are objects, but unlike a classical system, there are no special methods or properties associated with a prototype. Any object can be a prototype, even an empty object. In fact, that's exactly what is associated with a constructor by default:
How does JavaScript define the behaviour of instances? JavaScript doesn't have a special syntax or special kind of object for that, it has "prototypes." Prototypes are objects, but unlike a classical system, there are no special methods or properties associated with a prototype. Any object can be a prototype, even an empty object. In fact, that's exactly what is associated with a constructor by default:

```javascript
function Nullo () {};
Expand Down

0 comments on commit 9f32485

Please sign in to comment.