Skip to content

Instantly share code, notes, and snippets.

@voigt
Created April 5, 2013 17:17
Show Gist options
  • Save voigt/5321005 to your computer and use it in GitHub Desktop.
Save voigt/5321005 to your computer and use it in GitHub Desktop.
JavaScript Classes
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