I am new to java script and I went through the following link to learn about classes. http://prototypejs.org/learn/class-inheritance. I tried running the below code in google chrome and it says "Uncaught: Reference Error: Class not defined" and I don't know why it says so. Can anyone help me through this.
here is the code, I copy pasted it from the above link:
var Person = Class.create();
Person.prototype = {
initialize: function(name) {
this.name = name;
},
say: function(message) {
return this.name + ': ' + message;
}
};
var guy = new Person('Miro');
guy.say('hi');
// -> "Miro: hi"
var Pirate = Class.create();
// inherit from Person class:
Pirate.prototype = Object.extend(new Person(), {
// redefine the speak method
say: function(message) {
return this.name + ': ' + message + ', yarr!';
}
});
var john = new Pirate('Long John');
john.say('ahoy matey');