This commit is contained in:
2023-06-01 20:58:56 +00:00
parent 33a56e4dc5
commit 17fcbd26e7
4 changed files with 90 additions and 10 deletions

View File

@@ -318,6 +318,11 @@ Object.defineProperty(Array.prototype, 'apply', {
Object.defineProperty(Array.prototype, 'scale', {
value: function(s) {
if (Array.isArray(s)) {
var c = this.slice();
c.forEach(function(x,i) { c[i] = x * s[i]; });
return c;
}
return this.map(function(x) { return x*s; });
}});