Skip to content

Instantly share code, notes, and snippets.


ryardley/function_prototype.js Secret

Last active Aug 29, 2015
What would you like to do?
var secret = 'Not telling!';
function Person(name){ = name;
this.greeting = 'Hello!';
Person.prototype.sayGreeting = function(){
return + ' 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
You can’t perform that action at this time.