added more to snippets

This commit is contained in:
Luke Slater 2011-08-24 02:20:13 +01:00
parent 3d843f6c96
commit e31cb1beb7

View File

@ -15,6 +15,18 @@ Array.prototype.collect = function(fun) {
}
};
Array.prototype.include = function(value) {
var includes = false;
for(var i=0;i<this.length;i++) {
if(this[i] == value) {
includes = true;
break;
}
}
return includes;
};
/*** String ***/
String.prototype.endsWith = function(needle) {
@ -27,7 +39,7 @@ String.prototype.endsWith = function(needle) {
};
String.prototype.startsWith = function(needle) {
var start = this.slice(0, this.length - needle.length);
var start = this.slice(0, needle.length);
if(needle === start) {
return true;
} else {
@ -44,3 +56,11 @@ Object.prototype.isFunction = function(obj) {
return false;
}
};
Object.prototype.isArray = function(obj) {
if(Object.prototype.toString.call(obj) === '[object Array]') {
return true;
} else {
return false;
}
};