| 1 | /** |
| 2 | * Extending exising functionality |
| 3 | */ |
| 4 | |
| 5 | Array.prototype.remove = function(element) |
| 6 | { |
| 7 | var index = this.indexOf(element); |
| 8 | |
| 9 | if (index > -1) |
| 10 | { |
| 11 | this.splice(index, 1); |
| 12 | } |
| 13 | else |
| 14 | { |
| 15 | console.error("Element not part of array!", this, element); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | Array.prototype.contains = function(element) |
| 20 | { |
| 21 | var index = this.indexOf(element); |
| 22 | |
| 23 | return index > -1; |
| 24 | } |
| 25 | |
| 26 | Math.clamp = function(number, min, max) |
| 27 | { |
| 28 | return Math.min(max, Math.max(min, number)); |
| 29 | } |