Test case details

Preparation Code

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script> <script src="http://digg.googlecode.com/files/Class-0.0.2.js"> </script> <script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.2.0/prototype.js"> </script>
var result = '';

Test cases

Test #1

var Animal = Class.create(); Animal.prototype = { initialize: function(name, sound) { this.name = name; this.sound = sound; }, speak: function() { result = (this.name + " says: " + this.sound + "!"); } }; var cat = new Animal('Kitty', 'Meow'); cat.speak();

Test #2

function Animal(name, sound) { this.name = name; this.sound = sound; } Animal.prototype.speak = function() { result = (this.name + " says: " + this.sound + "!"); } var cat = new Animal('Kitty', 'Meow'); cat.speak();

Test #3

var Animal = { init: function(name, sound) { this.name = name; this.sound = sound; }, speak: function() { result = (this.name + " says: " + this.sound + "!"); }, }; var cat = Object.create(Animal); cat.init('Kitty', 'Meow'); cat.speak();

Test #4

var Animal = Class.create({ init: function(name, sound) { this.name = name; this.sound = sound; }, speak: function() { result = (this.name + " says: " + this.sound + "!"); } }); var cat = new Animal('Kitty', 'Meow'); cat.speak();