assuming .indexOf() is implemented
Object.defineProperty( Array.prototype,'has', { value:function(o){ if(typeof o === "string" || typeof o === "number"){ return this.indexOf(o) !== -1; } else{ // comparing non scalar for(var v in this){ if(JSON.stringify(this[v]) === JSON.stringify(o)) return true; } return false; }, // writable:false, // enumerable:false } ) !!! do not make Array.prototype.has because then the method is enumerable and js is broken
//use like [22 ,'a', {prop:'x'}].has(12) // false ["a","b"].has("a") // true [1,{a:1}].has({a:1}) // true