Bug 4203 - hasOwnProperty() returns true for Object.protoype properties
Summary: hasOwnProperty() returns true for Object.protoype properties
Status: RESOLVED DUPLICATE of bug 3293
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Maciej Stachowiak
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-29 10:55 PDT by Vicki Murley
Modified: 2005-07-29 14:56 PDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vicki Murley 2005-07-29 10:55:08 PDT
This bug is also in Radar as <rdar://4190700>

See http://phrogz.net/JS/hasOwnProperty_test.html:  

Object.prototype.toSourceCode = function(){ /*stuff*/ }

var animalSounds = { cat:'meow', dog:'woof' };
var output = '';

for (var animal in animalSounds){
  if ( !animalSounds.hasOwnProperty || animalSounds.hasOwnProperty(animal) ){
        output += 'The '+animal+' says "'+animalSounds[animal]+'"\n';
  }
}

Expected output:
The cat says "meow"
The dog says "woof"

Actual output from Safari 2.0 release 1:
The toSourceCode says "function () 
{
}"
The cat says "meow"
The dog says "woof"

-------------------------------------------
Comment 1 Maciej Stachowiak 2005-07-29 14:56:01 PDT
Already fixed.

*** This bug has been marked as a duplicate of 3293 ***