Yeah, I asked this on actual JS forum and just got ... Which is quite sad, because I am relatively thick skinned. But others might not be, so next time they are about to do things that are bad, they won't ask and they'll just make ty code :/ Regardless, I've been adding a very small amount to various native objects. Here are the ones I've made:
The Array class.
The Math class.
This is not a native class(I think), but similar concept.
I've added these function because they are functions I feel are quite relevant, as I often feel a need for them. But if it is actually bad, then I'd like to know why. Because I honestly don't understand why it would be an issue at all :/
The Array class.
JavaScript:
Array.prototype.remove = function(n) {
this.splice(n, 1);
};
Array.prototype.removeEmpty = function() {
for (var i = 0; i < this.length; i++) {
if (!this[i]) {
this.remove(i);
i--;
}
}
};
The Math class.
JavaScript:
Math.floorRandom = function(x) {
return Math.floor(Math.random() * x);
}
Math.roundRandom = function(x) {
return Math.round(Math.random() * x);
}
Math.ceilRandom = function(x) {
return Math.ceil(Math.random() * x);
}
This is not a native class(I think), but similar concept.
JavaScript:
console.show = function(content) {
require("nw.gui").Window.get().showDevTools();
if (content) console.log(content);
};
console.popError = function(content) {
require("nw.gui").Window.get().showDevTools();
if (content) console.error(content);
};
I've added these function because they are functions I feel are quite relevant, as I often feel a need for them. But if it is actually bad, then I'd like to know why. Because I honestly don't understand why it would be an issue at all :/