Skip to content

Instantly share code, notes, and snippets.

@peterpme
Created March 13, 2014 14:16
Show Gist options
  • Save peterpme/9529323 to your computer and use it in GitHub Desktop.
Save peterpme/9529323 to your computer and use it in GitHub Desktop.
Javascript: This example and Inheritance.
function Obj(name) {
var that = this;
this.name = name || "world";
return {
name : "Peter",
greet1 : function (arg1) {
return arg1 + this.name;
},
greet2 : function (arg1) {
return arg1 + that.name;
},
greet3 : (function (arg1) {
return arg1 + this.name;
}).bind(this, "goodbye ")
};
}
var x = new Obj();
console.log(x.greet1("hello "));
console.log(x.greet2("hello "));
//console.log(x.greet3()); */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment