Created
March 13, 2014 14:16
-
-
Save peterpme/9529323 to your computer and use it in GitHub Desktop.
Javascript: This example and Inheritance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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