Skip to content

Instantly share code, notes, and snippets.

@britter
Created May 2, 2014 16:55
Show Gist options
  • Save britter/26026b3cdc3a332d9d74 to your computer and use it in GitHub Desktop.
Save britter/26026b3cdc3a332d9d74 to your computer and use it in GitHub Desktop.
function Person(first,last,age) {
this.firstname = first;
this.lastname = last;
this.age = age;
var bankBalance = 7500;
var returnBalance = function() {
return bankBalance;
};
// create the new function here
this.askTeller = function() {
return this.returnBalance;
};
}
var john = new Person('John','Smith',30);
console.log(john.askTeller());
console.log(john.returnBalance);
var myBalanceMethod = john.askTeller();
var myBalance = myBalanceMethod();
console.log(myBalance);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment