Object.defineProperty polyfill

前端 未结 1 398
名媛妹妹
名媛妹妹 2020-12-16 07:15

I am currently writing a JavaScript API which is based on new features in ES5. It uses Object.defineProperty quite extensively. I have wrapped this into two new

相关标签:
1条回答
  • 2020-12-16 07:40

    For clarity, you might want to stick with standard terminology and name your routines defineDataProperty and defineAccessorProperty.

    Also, your enumerable: enumerable || true is going to result in a value of true even if the caller passes in false...

    Anyway, to get down to the question at hand: you can't do this in IE8. It is said that defineProperty works in IE8 but only on DOM objects. There are ugly hacks for IE7 and below involving using the onpropertychanged event on DOM objects. All of this has been gone over in some detail in other questions, such as Cross-browser Getter and Setter, JavaScript getter support in IE8, and many others.

    0 讨论(0)
提交回复
热议问题