2

On Firefox:

console.log(document.createElement('input').placeholder === ''); // true

console.log(document.createElement('input').hasOwnProperty('placeholder')); // false

I think the 2nd line codes should return true just like what you can see on Chrome. But I get false. Why?

Thank you!

weilou
  • 4,419
  • 10
  • 43
  • 56

1 Answers1

1

The spec defines the JS property as being on the prototype, not on the object itself. Chrome gets this wrong for all DOM properties; it's a longstanding bug in Chrome.

Boris Zbarsky
  • 34,758
  • 5
  • 52
  • 55
  • I think your answer is right! Thank you! This should be a WebKit's bug relevant its implementation to DOM. Safari also has this bug. – weilou Feb 23 '12 at 02:41