Created
July 13, 2010 16:04
-
-
Save ryana/474090 to your computer and use it in GitHub Desktop.
This file contains 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
var myObj = { | |
number: 10, | |
createElementsPType: function() { | |
new_element.click(this.showNumber.bind(this)); | |
} | |
createElementsjQuery: function() { | |
new_element.click(this.showNumber); | |
}, | |
showNumber: function() { | |
// in jQuery, this is element not myObj | |
// in pType, this == myObj because of bind | |
alert(this.number); | |
} | |
newElement: function() { | |
// do stuff and return a new element | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment