BlueGit

timfa frameworkv3

Files

frameworkv3 / framework / extentions.js

extentions.js

Framework 3
timfa Tim Falken · pushed by timfa · 9 years ago
4a56d325 History
extentions.js 490 B Download Raw
1/**
2 * Extending exising functionality
3 */
4
5Array.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
19Array.prototype.contains = function(element)
20{
21 var index = this.indexOf(element);
22
23 return index > -1;
24}
25
26Math.clamp = function(number, min, max)
27{
28 return Math.min(max, Math.max(min, number));
29}