D
dennis.sprengers
I've compared some open-source javascript editors, and found different
techniques for constructing the code. Two examples:
CodePress.run = function() {
new CodePress(t);
}
CodePress = function(obj) {
self.initialize = function() {}
self.toggleLineNumbers = function() {}
self.getCode = function() {}
}
-----------------------------------------------
function widgInit() {
new widgEditor(textarea.id)
}
function widgEditor(id) {
this.theToolbar = new widgToolbar(this);
}
function widgToolbar(theEditor) {}
widgToolbar.prototype.addButton = function() {}
widgToolbar.prototype.setState = function() {}
-----------------------------------------------
Could somebody explain to me the difference in the first method, which
defines one object that holds all methods in one class (as I
understand it) and the second method, which uses prototype functions.
I am confused because I thought that prototype functions were only
used to extend methods on strings and arrays. Please enlighten me
All help is greatly appreciated.
techniques for constructing the code. Two examples:
CodePress.run = function() {
new CodePress(t);
}
CodePress = function(obj) {
self.initialize = function() {}
self.toggleLineNumbers = function() {}
self.getCode = function() {}
}
-----------------------------------------------
function widgInit() {
new widgEditor(textarea.id)
}
function widgEditor(id) {
this.theToolbar = new widgToolbar(this);
}
function widgToolbar(theEditor) {}
widgToolbar.prototype.addButton = function() {}
widgToolbar.prototype.setState = function() {}
-----------------------------------------------
Could somebody explain to me the difference in the first method, which
defines one object that holds all methods in one class (as I
understand it) and the second method, which uses prototype functions.
I am confused because I thought that prototype functions were only
used to extend methods on strings and arrays. Please enlighten me
All help is greatly appreciated.