Curious about how prototyping works and if there is a workaround for my problem. Say I create a new function for Objects called 'keyExists':

Code JavaScript:
Object.prototype.keyExists=function(key)
{
   for(var tempKey in this)
      if(tempKey==key)
         return true;
 
   return false;
};
When I use this function, one of the keys in the iteration will be the new function that I have created.

The following example would alert the following: "key1", "key2", "keyExists". The last one is my concern. Obviously their are other browser-defined functions available for Objects that don't show up when iterating through the object. I thought Object.prototype.functionname was the methodology for that but apparently not. Is there a way to achieve the effect I am looking for?

Code JavaScript:
Object.prototype.keyExists=function(key)
{
   for(var tempKey in this)
   {
      alert(tempKey);
 
      if(tempKey==key)
         return true;
   }
 
   return false;
};
 
var testObject={"key1":"key1val", "key2":"key2val"};
 
testObject.keyExists("key3");