Is it safe when creating a custom object to give it methods (in my current case, "read", "write" and "save") that overwrite js native functions?
The object in question will never have to write to the DOM (or otherwise use the functions (s) that it will play); these method names are just perfect, so I was curious, and then I was surprised when it was difficult for me to find a clear answer to this question. An example is below. Thank you
Ticket = function (category, issuedBy, reissuable) {
this.id = Date.now().toString();
this.category = category;
this.resolved = false;
this.issuingMethod = issuedBy;
this.reissuable = reissuable === true;
this.data = {};
this.resolve = function () { return this.resolved = true;};
this.read = function (dataPath) {
this.write = function (dataPath, value) {
return this;
};
source
share