This operator checks if a key exists in an object and it can be used very simple like below:
var o = { 8:2008, 9:2009, 10:2010 }; 8 in o; // true, key 8 exists with a value of 2008 1 in o; // false, the key 1 does not exist in o
var o = { 8:2008, 9:2009, 10:2010 }; 8 in o; // true, key 8 exists with a value of 2008 1 in o; // false, the key 1 does not exist in o
Array.prototype.contains = function(value) { for (var i = 0; i < this.length; i++) if (this[i] == value) return true; return false; }
var myArray = ["a", "b", "c"]; myArray.contains("c"); // true