Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
var secret = 'Not telling!';
function Person(name){
this.name = name;
this.greeting = 'Hello!';
}
Person.prototype.sayGreeting = function(){
return this.name + ' says, "' + this.greeting + '"';
};
Person.prototype.getSecret = function(){
return secret;
};
var jane = new Person('Jane');
jane.sayGreeting(); // Jane says, "Hello!"
jane.getSecret(); // Not telling!
expect(jane instanceof Person).toBe(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment