Skip to content

Instantly share code, notes, and snippets.

@ryardley
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryardley/f52f9dceded74d14e102 to your computer and use it in GitHub Desktop.
Save ryardley/f52f9dceded74d14e102 to your computer and use it in GitHub Desktop.
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