Created
April 5, 2013 17:17
-
-
Save voigt/5321005 to your computer and use it in GitHub Desktop.
JavaScript Classes
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 Kasten = function () { | |
this.div = '.kasten1'; | |
this.top = $(div).offset().top; | |
this.bottom = $(div).offset().top + $(div).height(); | |
this.height = $(div).height(); | |
}; | |
Kasten.prototype.doCrazy = function () { | |
return this.top; | |
}; | |
var a = new Kasten(); | |
a.div = '.bl'; | |
var b = new Kasten(); | |
b.div = '.asd' | |
a.doCrazy = function() {}; | |
console.log(a); | |
/* | |
div | |
top | |
bottom | |
height | |
doCrazy() | |
*/ | |
console.log(a.__proto__); | |
/* | |
doCrazy | |
*/ | |
JSON.stringify(a); | |
/* | |
div | |
top | |
bottom | |
height | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment